Peter
Peter

Reputation: 11890

Why is zoom implemented differently in Camera2 API?

In my Android app, I am trying to implement camera zooming using Camera2 API. There are numerous examples on how to implement zoom using Camera2 API. One such example is mentioned at Zoom Camera2 Preview using TextureView. Here is the essential code snippet:

float maxZoom = characteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM));
currentZoom = adjustZoom(currentZoom, maxZoom);
Rect m = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
Rect m1 = cropRectangleBasedOnZoom(m1, curZoom);
previewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, m1);
...

This seems to work. However, the old Camera1 API has a simple method to set the zoom value. Why one has to go through the extra logic of adjusting a region in Camera2 API? Does the Camera2 logic results in better picture quality?

Also, is there a way to obtain the value of maximum optical zoom? Regards.

Upvotes: 0

Views: 1448

Answers (1)

Eddy Talvala
Eddy Talvala

Reputation: 18107

With Camera2, devices can support off-axis zoom, which is more flexible than the old API design. That said, not all devices support that feature, and you can check if a device does via SCALER_CROPPING_TYPE.

And in general, camera2 tries to tie all coordinates to the sensor active array, so it's always clear what part of the sensor is being considered, so it's a matter of consistency.

Optical zoom isn't supported via the crop region; it's strictly about digital zoom. If optical zoom is supported by a device, it's via AVAILABLE_FOCAL_LENGTHS and LENS_FOCAL_LENGTH.

Upvotes: 1

Related Questions