Ask Your Question

Albert's profile - activity

2016-01-26 03:32:28 -0500 received badge  Enthusiast
2016-01-15 07:44:30 -0500 received badge  Editor (source)
2016-01-14 06:33:19 -0500 received badge  Scholar (source)
2016-01-14 06:33:14 -0500 answered a question Camera Flash with OpenCV3.0.0 Android not working767

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();

       }
     }
 }

}
2016-01-07 06:23:19 -0500 commented question Camera Flash with OpenCV3.0.0 Android not working767

i found the answer here by applying then class form this source link text

but i can't add it as answer until tomorrow

2016-01-06 10:09:19 -0500 commented question Camera Flash with OpenCV3.0.0 Android not working767

i'm using Opencv3.0.0 for video processing, and i have red a tutorial that says i need to create another class extends JavaCameraView in order to turn on the flash link text. after creating the required class according to the tutorial i modified some lines in my activity as shown above, but I'm getting an error. so I'm asking if this method works with video processing or i need to implement something else. @berak

2016-01-06 09:42:35 -0500 asked a question 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) {
    mCamera.getParameters();
    Camera.Parameters params = mCamera.getParameters();
    params.setFlashMode(effect);
    mCamera.setParameters(params);

}
public List<Camera.Size> getResolutionList() {
    return mCamera.getParameters().getSupportedPreviewSizes();
}
public void setResolution(int w, int h) {
    disconnectCamera();
    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
    mCamera.setPreviewCallback(null);

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

@Override
public void onPictureTaken(byte[] data, Camera camera) {
    // The camera preview was automatically stopped. Start it again.
    mCamera.startPreview();
    mCamera.setPreviewCallback(this);

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

}

public void cameraRelease() {
    if(mCamera != null){
        mCamera.release();
    }
}

}

and when i call this line i get the error :

private CameraCustomize mOpenCvCameraView;
mOpenCvCameraView.setEffect(Camera.Parameters.FLASH_MODE_ON);

the error is in mCamera.setParameters(params);

Thank you in advanced