I am creating Android camera app using google sample. After the phone captures an image there is a difference of image quality. The camera preview has better image quality than the output image. How can I increase the quality of output image? After pinch zoom the difference of quality of preview image and output image even increases. This is my photo fragment and it's base class.
Asked
Active
Viewed 9,805 times
7
-
2Don't link to code. Post it here. – Gabe Sechan Jan 23 '17 at 00:23
1 Answers
11
The only way you have to increase your image quality is increasing your ImageReaderSize to a biggest resolution:
mImageReader = ImageReader.newInstance(pictureSizeValue.getWidth(), pictureSizeValue.getHeight(), format, maxImages);
Also, you can improve the quality using the key CaptureRequest.JPEG_QUALITY
in your CaptureRequest
.
mCaptureRequestBuilder.set(CaptureRequest.JPEG_QUALITY, (byte) 100);
But, to be honest, the difference between 91-100 of JPEG_QUALITY
values are minimal, and you will get a bigger image in the process. You can check the curve between quality-size here:

halfer
- 19,824
- 17
- 99
- 186

Francisco Durdin Garcia
- 12,540
- 9
- 53
- 95
-
Hi @Francisco Durdin Garcia . Thank you for your reply. I already added to my project: Size largest = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea()); mImageReader = imageReader.newInstance(largest.getWidth(), largest.getHeight(), ImageFormat.JPEG, /*maxImages*/1); and also: captureBuilder.set(CaptureRequest.JPEG_QUALITY, (byte)100); It works fine on Nexus 5X device, but it is not working properly on Samsung devices as Note 5. Do you have any idea how to fix this issue for Samsung devices? – Dylan Jan 23 '17 at 15:15
-
What do you mean with "It doesnt work fine"? If your want the higher possibly quality you should set yo tour imageReader the Max size retrieved from tour ResolutionMap in CameraCharacteristics – Francisco Durdin Garcia Jan 23 '17 at 17:50
-
For pinch zoom I used this code example http://stackoverflow.com/a/35289982/4836875 After the zooming the output image has not the same quality as the camera preview. Can be the problem in zooming code itself? – Dylan Jan 23 '17 at 18:30
-
When you use Zoom, you are doing a "digital" zoom. Camera API2 doesn't support a conventional zoom like a normal camera, it is just croping the preview rectangle, making bigger your image, and of course, losing quality. You can read more about how it works here : https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION – Francisco Durdin Garcia Jan 23 '17 at 21:34