如何将人脸检测纳入我的相机应用程序生命周期中?
我写了一个启动相机的应用程序。我想包括面部检测。我发现一些代码可以检测给定位图图像中的面部,但该图像是从 res/drawable 目录加载的。我想要的是扫描相机的脸部预览。任何人都可以阐明哪种相机方法应该处理检测。例如,我将在 surfaceChanged() 中进行检测吗?我知道我可能需要使用预览回调方法。谁能指出我正确的方向 谢谢
i've written an app that starts up the camera. i'd like to include face detection. i've found some code that detects faces in a given bitmap image but this image is loaded from the res/drawable directory. What i'm wanting is to scan the camera's preview for faces. can anyone shed light on which camera method should handle the detection. for example is it the surfaceChanged() where i would do the detection? i understand that i may need to use a previewcallback method. can anyone point me in the correct direction
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
本教程来自新的 Android 人脸检测器 API,展示了如何将人脸检测器与相机预览结合使用:
https://developers.google.com/vision/face-tracker-tutorial
This tutorial from the new Android face detector API shows how to use the face detector in conjunction with the camera preview:
https://developers.google.com/vision/face-tracker-tutorial
您可以使用第三方库(例如 OpenCV)或 Android2.2 人脸检测 Api 之类的库来完成该工作。你应该小心,因为预览回调会给你一个 yuv 字节数组,所以你需要将它传输到 rgb。
You may use a third-party libraries ,like OpenCV, or something like the Android2.2 face detection Api to finish that job. And you should by careful as the previewcallback will give you a yuv byte array, so you need to transfer it to rgb.