Reputation: 1759
I just upgraded my OpenCV version from 2.4 to 3.1. I'm using python with it. Before upgrading, the following code would return the label of the predicted image and the confidence label:
label, confidence = model.predict(test_sample_image)
However, after the upgrade, the above code gives an error:
Traceback (most recent call last):
File "recognize.py", line 45, in <module>
label, confidence = model.predict(test_sample_image)
TypeError: 'int' object is not iterable
meaning that an integer is returned instead of a tuple as before. So how do I get the confidence?
Upvotes: 3
Views: 1394
Reputation: 169
I think you should pass the cropped_face data like as (gray[x:x+w, y:y+h])
instead of test_sample_image
.
Upvotes: 0
Reputation: 2521
Mikebarson is right, I went to that line and found it different to the one on the current version, according to git it was changed on April 20, 2016.
However if you want a solution that doesn't involve rebuilding you can try what Jaco van Oost suggested here. It worked for me:
result = cv2.face.MinDistancePredictCollector()
recognizer.predict()
label = result.getLabel()
confidence = result.getDist()
Upvotes: 0
Reputation: 622
I've think I've found the solution to your problem. Click here
Open the file: opencv_contrib/modules/face/include/opencv2/face.hpp
If you go to line 259 on that file you should find it different than what was in the repositiory
It should just work after that. Cheers!
Upvotes: 3