我正在试验 Mobile Vision API 的人脸检测。我正在尝试获取面部标志的轮廓。但在构建 FaceDetector 时,它给了我这个异常(exception):
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.camera2tut, PID: 27106
java.lang.IllegalArgumentException: Invalid build options
FaceDetector 告诉我“非自拍模式不支持轮廓”。这是我设置 FaceDetector 的代码:
import com.google.android.gms.vision.face.FaceDetector;
[...]
mFaceDetector = new FaceDetector.Builder(this)
.setTrackingEnabled(true)
.setMinFaceSize((float)0.4)
.setLandmarkType(FaceDetector.CONTOUR_LANDMARKS)
.setClassificationType(FaceDetector.NO_CLASSIFICATIONS)
.setProminentFaceOnly(true)
.setMode(FaceDetector.ACCURATE_MODE)
.build();
对于 FaceDetector.Builder,没有设置“自拍模式”的选项: https://developers.google.com/android/reference/com/google/android/gms/vision/face/FaceDetector.Builder
尽管 FaceDetector 有一个常量 SELFIE_MODE: https://developers.google.com/android/reference/com/google/android/gms/vision/face/FaceDetector
从这个常量的描述来看,.setProminentFaceOnly(true)
似乎最接近自拍模式,但似乎并没有启用它。
如果我只是使用 .setLandmarkType(FaceDetector.ALL_LANDMARKS)
检测地标,则可以构建检测器。但如何使用这种不祥的“自拍”模式,如何获取轮廓?
最佳答案
你试过吗
.setMode(FaceDetector.SELFIE_MODE)
关于Java - Android Mobile Vision人脸检测与轮廓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55147188/