Search code examples
androidgoogle-play-servicesandroid-vision

Android Mobile Vision access to camera parameters


Is it posible access to Camera parameters in CameraSource on Android's Mobile Vision API 8.4? I want to be able to adjust some Camera parameters (Shutter speed, ISO, aperture,...).

UPDATE I try to do it using this code:

public Camera getCamera(CameraSource cameraSource) {

    Field[] declaredFields = CameraSource.class.getDeclaredFields();
    for (Field field : declaredFields) {
        if (field.getType() == Camera.class) {
            field.setAccessible(true);
            try {
                Camera camera = (Camera) field.get(cameraSource);
                if (camera != null) {
                    return camera;
                }

                return null;
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }

            break;
        }
    }

    return null;
}

But it doesn´t work for me, field.get(cameraSource); return null when get the field with type Camera.class.

Android-Vision team, do you plan to add these feature in the next releases?

Best regards,

Christian


Solution

  • We have no plans to expose the underlying camera in the official API. But there's an open source version of this class that you can use and modify:

    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