[英]Issue with preview callback [ANDROID]
I am doing an Android application that uses camera. 我正在做一个使用相机的Android应用程序。 I am using facedetection listener and runs fine, but when i try to add also a preview callback to do some proccess tasks, face detection stops running. 我正在使用facedetection侦听器并且运行正常,但是当我尝试添加预览回调以执行某些进程任务时,面部检测会停止运行。
Why?? 为什么??
This is my code: 这是我的代码:
@Override
public void surfaceCreated(SurfaceHolder holder) {
mCamera = StartCapture();
mCamera.setPreviewCallback(framesCallback);
mCamera.setFaceDetectionListener(faceDetectionListener);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
if (mCamera != null) {
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
mCamera.startFaceDetection();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
mCamera.stopFaceDetection();
mCamera.stopPreview();
mCamera.release();
mCamera = null;
}
This is logcat that produces when I use both of them: 这是我同时使用它们时产生的logcat:
02-11 14:35:14.376: E/mm-camera-img(197): FACEPROC_Detection returned error: -3
02-11 14:35:14.376: E/mm-camera-img(197): face_proc_thread_loop:466] frameproc exec error -1
02-11 14:35:14.510: E/mm-camera-img(197): FACEPROC_Detection returned error: -3
02-11 14:35:14.510: E/mm-camera-img(197): face_proc_thread_loop:466] frameproc exec error -1
02-11 14:35:14.643: E/mm-camera-img(197): FACEPROC_Detection returned error: -3
02-11 14:35:14.643: E/mm-camera-img(197): face_proc_thread_loop:466] frameproc exec error -1
It's too late for answer, but I had a same situation. 答案为时已晚,但我遇到了同样的情况。 After moving the position of setPreviewCallback() below startFaceDetection(), it works. 将setPreviewCallback()的位置移动到startFaceDetection()之后,它可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.