1

I am recording video using MediaRecorder. With CONTROL_VIDEO_STABILIZATION_MODE_OFF the entire camera image is visible on my surface view, however when I set CONTROL_VIDEO_STABILIZATION_MODE_ON the video and preview appear to be cropped slightly.

I would like to know the cropping amount so I can find the actual zoom level.

The value of CaptureRequest.CONTROL_ZOOM_RATIO does not change when stabilization is on or off.

Is it possible to find the amount of horizontal and vertical image cropping for the active stabilization mode?

Or are there any alternatives to CONTROL_ZOOM_RATIO that take into account the amount of cropping added by the image stabilization?

--

I am not sure if SCALER_CROP_REGION is adjusted when enabling stabilization:

Rect zoomCrop = mCaptureRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
Log.d(TAG, "ZOOM_1: " + zoomCrop);
   
mCaptureRequestBuilder.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, CameraMetadata.CONTROL_VIDEO_STABILIZATION_MODE_ON);
mCaptureRequestBuilder.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, CameraMetadata.LENS_OPTICAL_STABILIZATION_MODE_ON);

Rect zoomCrop2 = mCaptureRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
Log.d(TAG, "ZOOM_2: " + zoomCrop2);

Both print the same:

ZOOM_1: Rect(0, 0 - 4032, 3024)

ZOOM_2: Rect(0, 0 - 4032, 3024)

I also tried printing the results after camera initialization:

surfaceCaptureCallback = new CameraCaptureSession.CaptureCallback() {
    @Override
    public void onCaptureStarted(CameraCaptureSession session, CaptureRequest request, long timestamp, long frameNumber) {
        super.onCaptureStarted(session, request, timestamp, frameNumber);

        Rect zoomCrop = mCaptureRequestBuilder.get(CaptureRequest.SCALER_CROP_REGION);
        Log.d(TAG, "ZOOM: " + zoomCrop);

Prints:

ZOOM: Rect(0, 0 - 4032, 3024)

I see the video from the camera is still being cropped if image stabilization is enabled. But the SCALER_CROP_REGION values are not changing.

I have tried setting a cropping value using SCALER_CROP_REGION, this further increases the apparent zoom of the image and seems to add to the image stabilization cropping, however the values in SCALER_CROP_REGION print the same values that I set. Still I can see slight additional cropping from the stabilization.

I'm just not sure how to find the total cropping being applied to the output video.

Logic1
  • 1,806
  • 3
  • 26
  • 43

1 Answers1

0

As per documentation, "If enabled, video stabilization can modify the android.scaler.cropRegion to keep the video stream stabilized."

Try checking SCALER_CROP_REGION before and after VDIS.

Wasim Ansari
  • 305
  • 1
  • 9
  • Thank you, I just tried your suggestion but wasn't able to see a difference in the crop region values after enabling and disabling image stabilization. I'm not sure if I am retrieving the value correctly. I updated my question hoping that it helps. – Logic1 Mar 21 '22 at 22:16
  • are you able to see fov change on your device ? what device are you using ?? – Wasim Ansari Mar 22 '22 at 05:02
  • @Logic1 Also do not used both OIS and stabilization toagther, as per android document it results in undesired results. – Wasim Ansari Mar 22 '22 at 05:04