Android 5.0预览表面上的裁剪区域错误并捕获了静止图像 [英] Android 5.0 Wrong crop regions on preview surface and captured still image

查看:303
本文介绍了Android 5.0预览表面上的裁剪区域错误并捕获了静止图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在带camera2界面的Android 5.0上获得数字缩放框. 该功能的适当文档为 developer.android.com/camera2/captureRequest

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宽高比)
  • ImageReader(3264x2448,4:3纵横比)

相机的传感器尺寸为3280x2464(长宽比为4:3)

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)

我将此Rect设置为预览请求的参数:

I set this Rect as parameter for preview request:

previewRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoomCropPreview);
captureSession.setRepeatingRequest(previewRequestBuilder.build(), null, null);

并拍摄静止图像:

stillRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoomCropPreview);

captureSession.capture(stillRequestBuilder.build(), new captureListener() , null);

预期结果:

  • Coz裁剪矩形比例为4:3,则预览应垂直裁剪(字母框)
  • 静止图像应该是准确的作物区域.
  • 预览和静止图像都应在场景的同一点上居中,并且仅在垂直边缘上应有所不同.

实际结果:

  • 预览和静止图像指向似乎垂直移动的不同场景.查看附加图像.
  • Preview and still image point on different scene which seems to be moved vertically. Look at attach images.

我在做什么错了?

推荐答案

已修复! 总体思路是分别计算预览和静止图像的裁剪区域.

Fixed! General idea is to calculate crop region for preview and still images separately.

1)如初始文章中所述计算静止图像的裁剪区域(使用4:3矩形)

1) Calculate crop region for still image as in initial post (use 4:3 rectangle)

2)要进行预览,请在裁剪区域(4:3)上方并减小垂直尺寸以获取16:9矩形.

2) For preview take above crop region (4:3) and reduce vertical size to get 16:9 rectangle.

这篇关于Android 5.0预览表面上的裁剪区域错误并捕获了静止图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆