Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Camera Flash with OpenCV3.0.0 Android not working767

I'm writing a code using OpenCV VIDEO PROCESSING, and i want to open the camera flash when first opening the camera. i have implemented a new class that is extended from JavaCameraView but the app crashes when i run it.

Anyone please can help me to fix the error, or tell me if there another way to make the flash works with VIDEO PROCESSING

the extended class that i use from this sourcelink text as the Following:

public class CameraCustomize extends JavaCameraView  implements Camera.PictureCallback {
private String mPictureFileName;

public CameraCustomize(Context context, AttributeSet attrs) {
    super(context, attrs);
public List<String> getEffectList() {
    return mCamera.getParameters().getSupportedFlashModes();
public boolean isEffectSupported() {
    return (mCamera.getParameters().getFlashMode() != null);
public String getEffect() {
    return mCamera.getParameters().getFlashMode();
public void setEffect(String effect) {
    Camera.Parameters params = mCamera.getParameters();

public List<Camera.Size> getResolutionList() {
    return mCamera.getParameters().getSupportedPreviewSizes();
public void setResolution(int w, int h) {
    mMaxHeight = h;
    mMaxWidth = w;
    connectCamera(getWidth(), getHeight());

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

public void takePicture(final String fileName) {
    this.mPictureFileName = fileName;
    // Postview and jpeg are sent in the same buffers if the queue is not empty when performing a capture.
    // Clear up buffers to avoid mCamera.takePicture to be stuck because of a memory issue

    // PictureCallback is implemented by the current class
    mCamera.takePicture(null, null, this);

public void onPictureTaken(byte[] data, Camera camera) {
    // The camera preview was automatically stopped. Start it again.

    // Write the image in a file (in jpeg format)
    try {
        FileOutputStream fos = new FileOutputStream(mPictureFileName);
    } catch ( e) {
        Log.e("PictureDemo", "Exception in photoCallback", e);


public void cameraRelease() {
    if(mCamera != null){


and when i call this line i get the error :

private CameraCustomize mOpenCvCameraView;

the error is in mCamera.setParameters(params);

Thank you in advanced