使用API​​14中的方法无法进行人脸检测 [英] Face detection not working using methods from API14

查看:116
本文介绍了使用API​​14中的方法无法进行人脸检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对API14中的人脸检测方法有疑问.我没有空的相机对象.我使用 setFaceDetectionListener 和FaceDecectionListener的非常简单的实现将其设置为侦听器.

I have a problem with face detection methods from API14. I have not null camera object. I set to it listener using setFaceDetectionListener with very simple implementation of FaceDecectionListener.

下一步,我将调用camera.startFaceDetection(),但永远不会调用接口方法 onFaceDetection(Face [] faces,Camera camera) ...这个简单的方法怎么了?相机可能有问题吗?我在SGS3和SGS4上测试了此功能,但我遇到了同样的问题.

I next step I call camera.startFaceDetection() but inteface method onFaceDetection(Face[] faces, Camera camera) is never call... What's wrong with this simple method? Maybe there's a problem with camera? I tested this function on SGS3 and SGS4 and I have the same problem.

推荐答案

好的,问题解决了.并非所有设备都支持相机预览中的人脸检测功能.它取决于设备.有些设备可能会崩溃,并显示 java.lang.IllegalArgumentException:无效的面部检测类型= 0 之类的消息,但是某些设备不执行任何操作,并且永远无法达到侦听器的方法.

OK guys, issue solved. Not all devices supports face detection function from camera preview. It's device-dependent. Some of devices can crash with message like java.lang.IllegalArgumentException: invalid face detection type=0 but some devices do nothing and listener's method is never reached.

在这种情况下,需要使用 Camera.getMaxNumDetectedFaces()检查设备是否支持此功能.如果此方法返回0,则可以确定我们的设备不支持API14中的人脸检测方法.

In this case it's needed to check that device support this function using Camera.getMaxNumDetectedFaces(). If this method returns 0 then we can be sure that our device does not support face detection methods from API14.

这篇关于使用API​​14中的方法无法进行人脸检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆