Skip to main content

OpenCVAndroid FlashLight code


First I get into JavaCameraView.java class in the OpenCV Library

and then in the initializeCamera add the following lines just before mCamera.startPreview();

private SurfaceTexture mSurfaceTexture1;
protected Camera mCamera;
mCamera = Camera.open();

Camera.Parameters p = mCamera.getParameters();

p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);

mCam.setParameters(p);

mSurfaceTexture1 = new SurfaceTexture(0);

try {

   mCamera.setPreviewTexture(mSurfaceTexture1);

} catch (IOException ex) {

   // Ignore

}

mCamera.startPreview();

Comments