Florian Echtler
Florian Echtler

Reputation: 2513

Disabling automatic image stabilization on Android (Moto Z)?

I'm writing a custom app using OpenCV for computer vision on an Android phone (Moto Z). To complicate things even more, I have a fisheye add-on lens attached to the camera.

Now, I've noticed that when I move the device while getting preview images, the circular region illuminated by the fisheye lens shifts noticeably and also jitters even when the device is not moving (see https://youtu.be/J4Ns0mzgFww for illustration, hard to describe).

The effect looks like the fisheye lens is physically shifting in front of the actual camera lens, but it is quite rigidly attached, and this happens even with very slow movements. So my only explanation is that there is some sort of low-level image stabilization process running somewhere in the background.

Unfortunately, this totally messes up my camera calibration, because cx/cy are no longer stable. I've had a look at how can i set the camera function that anti-shake(image Stabilizer) at android, but the Camera.Parameters object tells me that video-stabilization-supported=false, and changing the scene mode also doesn't make any difference.

Any other hints/ideas regarding how to get unstabilized preview images? I suppose using the Camera2 API in RAW mode might work, but that would mean rewriting a large chunk of the OpenCV image acquisition code... alternatives preferred :-)

Upvotes: 3

Views: 805

Answers (1)

Florian Echtler
Florian Echtler

Reputation: 2513

As usual, I figured it out myself 15 minutes after posting the question. Oh well. Anyway.

This is possible with the Camera2 API via

requestBuilder.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, 
  CameraMetadata.LENS_OPTICAL_STABILIZATION_MODE_OFF);

Still means I'll have to switch to Camera2 API, but at least not to RAW. Since 4.0, OpenCV actually has a ready-made JavaCamera2View class that only needed minor modifications. Further details/docs available at https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#LENS_OPTICAL_STABILIZATION_MODE.

Upvotes: 1

Related Questions