如何使用opencv3 LBPHFaceRecognizer和python3获得信心

时间:2016-12-12 19:49:27

标签: python-3.x opencv3.0

我看到的例子是predict()返回(id,置信度),但是当我用cv2和python3尝试时,我收到错误TypeError: 'int' object is not iterable

recognizer = cv2.face.createLBPHFaceRecognizer()
recognizer.load('trained.yml')

# This throws the error
name_id, confidence = recognizer.predict(frame) 
# This runs
name_id = recognizer.predict(frame) 

还有其他方式可以获得信心吗?

1 个答案:

答案 0 :(得分:0)

prediction = model.predict(face_resize)
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 3)
print prediction

if prediction[1]>50 and prediction[1]<85:
cv2.putText(frame,
  '%s - %.0f' % (names[prediction[0]],prediction[1]),
  (x-10, y-10), cv2.FONT_HERSHEY_PLAIN,1,(0, 255, 0))                   
else:
cv2.putText(frame,
  'Unknown',
  (x-10, y-10), cv2.FONT_HERSHEY_PLAIN,1,(0, 0, 255))