开发者

android camera preview callback is drawing overlay view very slowly

开发者 https://www.devze.com 2023-02-22 00:49 出处:网络
I am using a face detector which follows detected faces as they move, using the Camera preview callback开发者_JAVA技巧 and drawing an overlay view on top of the preview display (where it draws circles

I am using a face detector which follows detected faces as they move, using the Camera preview callback开发者_JAVA技巧 and drawing an overlay view on top of the preview display (where it draws circles around the faces).

It all works, but it lags by 2 or 3 seconds by the time the view has changed, the drawn circles show up too late. I am calling invalidate on the overlay view in the onPreviewFrame method.

Any ideas what is wrong? Is the android FaceDetector's findFaces method just really slow? It seems to take ~about .5 seconds max when I check with system time, which is a lot less than 3 seconds.

Any help would be appreciated. Thank you!


0.5 - 1 sec is the time a face is detected by FaceDetector.findFaces method.


FaceDetector is built to detect faces in arbitrary bitmaps. Since you are wanting to detect faces in an active camera preview perhaps you might try using the Camera.FaceDetectionListener implementation of face detection as described here:

http://developer.android.com/guide/topics/media/camera.html#face-detection

It is likely that this method of detecting faces is optimized for working in concert with an active camera preview frame.

As well, try opening the stock Android camera app on your device and watch as it detects faces. Does it detect them at the same speed as the face detection in your app? If it's faster, then there's likely something you can do to make your app faster. If not, then your app is likely already as fast as it will get on that device.

For reference, face detection in the stock app on my Nexus 4 averages probably about 0.2s (5 per second) and on my Nexus 10 is a bit slower, probably at about 0.33s (3 per second.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号