Cropping

对full pixel array进行crop(用于digital zoom和其他需要较小FOV的场景)是通过设置ANDROID_SCALER_CROP_REGION来和底层沟通的。这是一个per-request setting,,并且可以在每个请求的基础上进行更改,这对于实现平滑的digital zoom(数字变焦)至关重要。

该CROP_REGION定义为矩形(x, y, width, height)),其中(x,y)为矩形的左上角的坐标。CROP_REGION是在sensor active pixel array的坐标系上定义的,其中(0,0)是active pixel array的左上像素。 因此,width (宽度)和 height(高度)不能超出ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY的尺寸。

HAL通过ANDROID_SCALER_MAX_DIGITAL_ZOOM上报最小允许的宽度和高度,该字段描述了最大支持的缩放系数(zoom factor.)。 因此,最小crop region 的宽度和高度为:

  {width, height} =
   { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] /
       ANDROID_SCALER_MAX_DIGITAL_ZOOM),
     floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] /
       ANDROID_SCALER_MAX_DIGITAL_ZOOM) }

如果crop region需要满足特定要求(例如,它需要从偶数坐标开始,并且其宽度/高度必须是偶数),HAL必须进行必要的舍入并将最终使用的crop region写入output resul metadata中。同样,如果HAL实现video stabilization,则必须在应用video stabilization后调整crop region以描述输出中实际包含的区域。通常,使用相机的应用程序必须能够基于crop region,sensor的尺寸和镜头的focal length确定它可以获得的FOV。

由于crop region适用于所有stream而且这些stream的宽高比可能与crop region不同,因此sensor region可能小于stream需要的crop region。具体来说,每个stream应通过最少的裁剪当前的crop region来保持square pixels及其宽高比。如果stream的宽高比和crop region的宽高比不一致则需要进一步裁剪.。在所有情况下,stream crop必须在整个crop region的中心进行,并且每个stream 仅相对于整个crop region水平或垂直裁剪,而不能两者都裁剪

例如,如果定义了两个stream,则在假设的 sensor的最大出图size为3 MP (2000 x 1500),下面的示例演示了640x480的stream(4:3)和1280x720的stream(16:9)的预期输出区域。

Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
640x480 stream crop: (500, 375, 1000, 750) (equal to crop region)
1280x720 stream crop: (500, 469, 1000, 562)

crop-region-43-ratio

                                Figure 1. 4:3 aspect ratio

Crop region: (500, 375, 1333, 750) (16:9 aspect ratio)
640x480 stream crop: (666, 375, 1000, 750)
1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region)

crop-region-169-ratio

                               Figure 2. 16:9 aspect ratio

Crop region: (500, 375, 750, 750) (1:1 aspect ratio)
640x480 stream crop: (500, 469, 750, 562)
1280x720 stream crop: (500, 543, 750, 414)

crop-region-11-ratio

                                 Figure 3. 1:1 aspect ratio

And a final example, a 1024x1024 square aspect ratio stream instead of the 480p stream:
Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
1024x1024 stream crop: (625, 375, 750, 750)
1280x720 stream crop: (500, 469, 1000, 562)

crop-region-43-square-ratio

                      Figure 4. 4:3 aspect ratio, square

原文地址:https://source.android.google.cn/devices/camera/camera3_crop_reprocess#cropping

发布了100 篇原创文章 · 获赞 175 · 访问量 54万+

猜你喜欢

转载自blog.csdn.net/f2006116/article/details/104068938