问题
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.
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.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/19011319/face-detection-not-working-using-methods-from-api14