When I am using the following code the result is that flash is ON but it gives error that " it seems that your device does not support camera (or it is locked).Application will be closed". Please suggest me a method so that see the camera preview with flash ON.
private Camera mCamera;
void ledOn(){
Camera.Parameters p = mCamera.getParameters();
p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(p);
}
I had the same problem. I modified some code and it's work:
public class OpenCvCameraView extends JavaCameraView {
public OpenCvCameraView(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) {
if(mCamera != null) {
mCamera.getParameters();
Camera.Parameters params = mCamera.getParameters();
params.setFlashMode(effect);
mCamera.setParameters(params);
}
}
public void cameraRelease() {
if(mCamera != null){
mCamera.release();
}
}
}
And put this methods into you main activity:
public void turnOnTorch() {
mOpenCVCameraView.setEffect(Camera.Parameters.FLASH_MODE_TORCH);
}
public void turnOffTorch() {
mOpenCVCameraView.setEffect(Camera.Parameters.FLASH_MODE_ON);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.