问题
After I call: cameraSource.takePicture(null, pictureCallback); in the callback:
private CameraSource.PictureCallback pictureCallback = new CameraSource.PictureCallback() {
@Override
public void onPictureTaken(byte[] bytes) {
try {
Log.d(DEBUG_TAG, "On picture taken.");
if (bytes == null) {
return;
}
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
Glide.with(this).load(bitmap).into(capturedImg);
}catch (Exception ex){
ex.printStackTrace();
Log.e("PictureTaken",ex.toString());
}
};
When the bitmap is created the resolution is very low (320x240). The camera is capable of taking higher resolution photos. around 1600x1200 from the normal camera app. But using the normal Camera api returns a resolution of 1280x720 for the same camera.
So only using the CameraSource from the Mobile Vision API returns a very low resolution image. But this is not consistent. It returns a high resolution on samsung tablets. But when I used the same code on my Lenovo tab 3, CameraSource returns a very low resolution image. What could be the problem and the possible fix?
回答1:
CameraSource class is open source, at least some version if it, https://github.com/googlesamples/android-vision/blob/master/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java. You are free to extend it to set better picture size.
来源:https://stackoverflow.com/questions/48187806/on-some-devices-google-mobile-visions-camerasource-returns-low-resolution-image