使用API 14我創建了一個Activity,它成功地使用了人臉檢測(我在這個人臉檢測方面有點新鮮)。人臉檢測是否需要SurfaceView才能正常工作?
但我不想顯示相機的預覽,我只想知道用戶的臉部位於相機的前方。我添加了幾個按鈕來使SurfaceView可見/不可見,並且我發現當它是INVISIBLE或GONE時,面部檢測停止工作。
有沒有辦法啓用面部檢測而不需要佈局中的SurfaceView?
這裏是我是如何編碼它:
mCamera.setPreviewDisplay(mSurfaceHolder);
mCamera.startPreview();
if(mCamera.getParameters().getMaxNumDetectedFaces() >0) {
mCamera.setFaceDetectionListener(new Camera.FaceDetectionListener() {
@Override public void onFaceDetection(Face[] faces, Camera camera) {
if(faces.length > 0) {
System.out.println("Found someone");
}
}
});
mCamera.startFaceDetection();
}
要隱藏surfaceview我添加了一個黑色觀看。 :-)
<View android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000"/>
我身邊有一個合理的外觀和我還沒有發現使用startFaceDetection()多的代碼呢。
感謝您的任何想法/幫助。
你有沒有找到這個問題的答案?我找到了一個使用人臉檢測的項目,但只嘗試使用沒有表面視圖的人臉檢測,我還沒有想出如何去做。 https://github.com/ProjPossibility/2014-CSUN-Cam4Blind – portfoliobuilder 2015-04-29 18:31:12