在Android Camera2 API中,如何设置自定义图像纵横比或分辨率?

问题描述 投票:0回答:1

[我希望我的Android应用使用自定义的宽高比或记录的宽度和高度(大约16:3)来扫描预览中的条形码。我希望摄像头传感器必须读出较少的像素,并且处理速度更快。但是我还没有找到任何可以使用自定义相机分辨率播放的Camera2 API的有效示例。这有可能吗?

android android-camera2
1个回答
0
投票

AFAIK,无法在拍摄照片之前直接告诉Camera2 API所需的分辨率。但是,请看this questionthis one。您可以使用所需的宽度和高度来创建ImageReader的实例,例如]

  //the size of the ImageReader determines the output from the camera.
  private ImageReader mImageReader = ImageReader.newInstance(mWidth, mHeight, ImageFormat.YV12, 30);

这样,您在查找条形码时将节省处理时间和内存。

© www.soinside.com 2019 - 2024. All rights reserved.