I'm trying to get digital zoomed frame on Android 5.0 with camera2 interface. Appropriate doc for that functionality is developer.android.com/camera2/captureRequest
Surface used in my application:
- SurafaceView (1920x1080, 16:9 aspect ratio)
- ImageReader (3264x2448, 4:3 aspect ratio)
Camera's sensor size is 3280x2464 (4:3 aspect ratio)
Crop region which I want to get from sensor is:
Rect zoomCropPreview = new Rect(1094, 822, 2186, 1642); //(1092x820, 4:3 aspect ratio)
I set this Rect as parameter for preview request:
previewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoomCropPreview);
captureSession.setRepeatingRequest(previewRequestBuilder.build(), null, null);
And to take still image:
stillRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoomCropPreview);
captureSession.capture(stillRequestBuilder.build(), new captureListener() , null);
Expected results:
- Coz crop rectangle is 4:3 ratio, then preview should be cropped vertically (letterbox)
- Still image should be exact crop region.
- Both preview and still image should be centered on the same point of scene, and should differ only in vertical edges.
Real result:
- Preview and still image point on different scene which seems to be moved vertically. Look at attach images.
What am I doing wrong?
Fixed! General idea is to calculate crop region for preview and still images separately.
1) Calculate crop region for still image as in initial post (use 4:3 rectangle)
2) For preview take above crop region (4:3) and reduce vertical size to get 16:9 rectangle.