0
我正在使用opencv
視頻流編寫代碼,並且我想在首次打開相機時打開相機閃光燈。我已經實施了從JavaCameraView
但應用程序崩潰擴展一個新的類時,我CAL這一行:使用OpenCV3.0.0的相機閃光燈Android不能使用
mOpencvCameraView.setEffect(Camera.Parameters.FLASH_MODE_ON);
類是由於以下幾點: 我的代碼
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();// here where i get the Error
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();
}
}
}
請任何一個可以幫助我,或者建議以其他方式啓動相機閃光燈。 謝謝你的高級。
? – sasikumar
yes如下所示:01-06 13:45:18.292 15148-15148/org.opencv.samples.facedetect E/AndroidRuntime:致命例外:main java.lang.RuntimeException:無法啓動活動ComponentInfo {org.opencv.samples .facedetect/org.opencv.samples.facedetect.FdActivity}:java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967) – Albert