I want my Android app to use a custom aspect ratio or recorded width and height, roughly 16:3, to scan a barcode in a preview. I expect that the camera sensor would have to read out less pixels and would be faster in processing. But I have not found any working example for Camera2 API that plays with custom camera resolutions. Is that possible at all?
Asked
Active
Viewed 782 times
1 Answers
0
AFAIK there is no way to directly tell Camera2 API the desired resolution before the picture is being taken. However, take a look at this question and this one. You can create an instance of ImageReader with the desired width and height like so
//the size of the ImageReader determines the output from the camera.
private ImageReader mImageReader = ImageReader.newInstance(mWidth, mHeight, ImageFormat.YV12, 30);
This way you will save processing time and memory when looking for the barcode.

nulldroid
- 1,150
- 8
- 15