Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I found the solution by applying this class from this link Using Camera LED Flash with OpenCV on Android

I found the solution by applying this class from this link Using Camera LED Flash with OpenCV on Android

.

Heres is the Class:

I found the solution by applying this class from this link Using Camera LED Flash with OpenCV on Android

it's just worked perfectly :)

Here is the Class that i've implemented:

private static final String TAG = "Sample::Tutorial2View";

private Context my reference;

private static boolean isFlashLightON = false;

public Tutorial2View(Context context, AttributeSet attrs) {
super(context, attrs);
this.myreference = context;
}

public List<String> getEffectList() {
return mCamera.getParameters().getSupportedColorEffects();
}

public boolean isEffectSupported() {
return (mCamera.getParameters().getColorEffect() != null);
}

public String getEffect() {
return mCamera.getParameters().getColorEffect();
}

public void setEffect(String effect) {
Camera.Parameters params = mCamera.getParameters();
params.setColorEffect(effect);
mCamera.setParameters(params);
}

public List<Size> getResolutionList() {
return mCamera.getParameters().getSupportedPreviewSizes();
}

 public void setResolution(Size resolution) {
 disconnectCamera();
mMaxHeight = resolution.height;
mMaxWidth = resolution.width;
connectCamera(getWidth(), getHeight());
}

public Size getResolution() {
return mCamera.getParameters().getPreviewSize();
}

// Setup the camera
public void setupCameraFlashLight() {
Camera  camera = mCamera;
if (camera != null) {
Parameters params = camera.getParameters();

if (params != null) {
    if (isFlashLightON) {
        isFlashLightON = false;
        params.setFlashMode(Parameters.FLASH_MODE_OFF);
        camera.setParameters(params);
        camera.startPreview();
    } else {
        isFlashLightON = true;
        params.setFlashMode(Parameters.FLASH_MODE_TORCH);
        camera.setParameters(params);
        camera.startPreview();

       }
     }
 }

}