opencv-face-recognition-python
opencv-face-recognition-python copied to clipboard
TypeError: list indices must be integers or slices, not tuple
Preparing data...
Data prepared
Total faces: 23
Total labels: 23
Predicting images...
Traceback (most recent call last):
File "/Users/avadhesh/Downloads/opencv-face-recognition-python-master/OpenCV-Face-Recognition-Python.py", line 329, in
Process finished with exit code 1
'label' is two value-> (1, 0.0)
first value is subjects label text count , second is.. I don't know.
so I change like this -> label_text = subjects[label[0]]
it's work.
Latest versions of OpenCV's predict function returns a (label, confidence)
tuple. The first value is the label of the subject identified and the second value is the confidence score for that subject. You can use the confidence to filter out low confidence images as unknown subjects. So @Clanatia is right
changing following
label_text = subjects[label]
to
label_text = subjects[label[0]]
should work fine on OpenCV versions which give this error.
AttributeError Traceback (most recent call last)
AttributeError: module 'cv2' has no attribute 'face' Why is this problem occurring?
AttributeError Traceback (most recent call last) in () ----> 1 face_recognizer = cv2.face.createLBPHFaceRecognizer() 2
AttributeError: module 'cv2' has no attribute 'face' Why is this problem occurring?
Use this instead: face_recognizer = cv2.face.LBPHFaceRecognizer_create()
AttributeError Traceback (most recent call last) in () ----> 1 face_recognizer = cv2.face.createLBPHFaceRecognizer() 2
AttributeError: module 'cv2' has no attribute 'face' Why is this problem occurring?
Try to install opencv using: python -m pip install --user opencv-contrib-python And then try cv2.face.HBPHFaceRecognizer_create()