I Have to implement in Google Vision API's CameraSource for build the camera and do the face detection on before capturing the image. Now I have faced few issues, So I need to access the camera object from CameraSource.
- How could I achieve the increase or Decrease the Camera Preview Brightness using CameraSource?
This is my CameraSource Builder
mCameraSource = new CameraSource.Builder(context, detector)
.setRequestedPreviewSize(640, 480)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(30.0f)
.build();
Here I have to try to access/get the camera from mCameraSource object.
Field[] declaredFields = CameraSource.class.getDeclaredFields();
for (Field field : declaredFields) {
if (field.getType() == Camera.class) {
field.setAccessible(true);
try {
Camera camera = (Camera) field.get(mCameraSource);
if (camera != null) {
Camera.Parameters params = camera.getParameters();
params.setExposureCompensation(1500);
camera.setParameters(params);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
but the camera
returns null only, And My 2nd Question is how to do brightness option...
if (camera != null) {
Camera.Parameters params = camera.getParameters();
params.setExposureCompensation(1500);
camera.setParameters(params);
}