简体   繁体   English

Android FaceDetector.Face Euler 角度一直为 0

[英]Android FaceDetector.Face Euler angles are 0 all the time

I'm trying to get a the Euler angle of a Face that is detected by FaceDetector.我正在尝试获取 FaceDetector 检测到的人脸的欧拉角。

Here is what I use to output to Logcat:这是我用于 output 到 Logcat 的内容:

Log.v("debug", " X: " + face.pose(Face.EULER_X) + " Y: " + face.pose(Face.EULER_Y) + " Z: " + face.pose(Face.EULER_Z) );

But it always returns 0.0 for all three, no matter what angle the face is at.但它总是为所有三个返回 0.0,无论面部处于什么角度。 Any ideas why?任何想法为什么?

Yeah the FaceDetector from API 1 never returns a pose angle.是的,API 1 中的FaceDetector永远不会返回姿势角度。 You can look at the source code to verify.您可以查看源代码进行验证。

The newer FaceDetectionListener from API 14 will return a pose angle, but it's only available on a limited number of devices right now. API 14 中较新的FaceDetectionListener将返回姿势角度,但目前仅在有限数量的设备上可用。 Not even all devices running API 14 can use it.甚至不是所有运行 API 14 的设备都可以使用它。 You have to call getMaxNumDetectedFaces() to see if your device supports that API.您必须调用getMaxNumDetectedFaces()来查看您的设备是否支持该 API。

You can alternately try using OpenCV.您也可以尝试使用 OpenCV。 A couple options for that are http://code.opencv.org/projects/opencv/wiki/OpenCV4Android and http://code.google.com/p/javacv/ .几个选项是http://code.opencv.org/projects/opencv/wiki/OpenCV4Androidhttp://code.google.com/p/javacv/ In my experience they aren't worth the hassle unless you really, really need the pose angle.根据我的经验,除非您真的非常需要姿势角度,否则它们不值得麻烦。

There are a few similar questions here.这里有几个类似的问题。 Check out the first answer from this link:查看此链接中的第一个答案:

Android Facedetector pose values are always 0 Android Facedetector 姿势值始终为 0

And see below for someone that says they solved the problem:看看下面有人说他们解决了这个问题:

Android Face Detection 安卓人脸检测

Set the detector setMode to ACCURATE_MODE将检测器setMode设置为ACCURATE_MODE

Here is an example that worked for me in Kotlin:这是一个在 Kotlin 中对我有用的示例:

val detector = FaceDetector.Builder(context)
            .setClassificationType(FaceDetector.ACCURATE_MODE)
            .setMode(FaceDetector.ACCURATE_MODE)
            .setTrackingEnabled(true)
            .build()

On the latest version developers needs to set the perfomance mode to PERFORMANCE_MODE_ACCURATE not PERFORMANCE_MODE_FAST在最新版本上,开发人员需要将性能模式设置为 PERFORMANCE_MODE_ACCURATE 而不是 PERFORMANCE_MODE_FAST

setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM