我正在使用 dlib 库进行人脸识别。它正在工作,但返回多个名称(匹配的人)。所以我想根据置信度值获得最佳匹配。但是这个方法总是为所有匹配的人返回 0.0 值。所以请帮我解决这个问题。
我试过这段代码。
List<VisionDetRet> results = mFaceRec.recognize(mCroppedBitmap);
long endTime = System.currentTimeMillis();
ArrayList<String> names = new ArrayList<>();
String finalMatch="";
float conf_val=0;
for (VisionDetRet n : results) {
System.out.println("confidence value = " + n.getConfidence());
if(conf_val<n.getConfidence()) {
conf_val=n.getConfidence();
finalMatch=n.getLabel();
}
}
if(finalMatch.length() != 0) {
names.add(finalMatch);
}
我使用了两个类识别器.h 和 jni_face_rec.cpp 来获得匹配置信度。