On some devices, Google Mobile Visions CameraSource returns low resolution image after calling takePicture

隐身守侯 提交于 2019-12-24 07:47:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!