所以我正在使用应该打开我的摄像头并进行人脸识别的代码,但这就是你
(facecourse-py2) lawn-128-61-17-230:face-recognition-opencv apaar$
python recognize_faces_video.py --encodings encodings.pickle --output output/webcam_face_recognition_output.avi --display 1
[INFO] loading encodings...
[INFO] starting video stream...
Traceback (most recent call last):
File "recognize_faces_video.py", line 60, in <module>
matches = int(face_recognition.compare_faces(data["encodings"],
TypeError: string indices must be integers, not str
第60行的代码如下:
for encoding in encodings:
# attempt to match each face in the input image to our known
# encodings
matches = int(face_recognition.compare_faces(data["encodings"],
encoding))
name = "Unknown"
答案 0 :(得分:0)
在评论部分,您说您将data
初始化为
data = pickle.dumps(open(args["encodings"], "rb").read())
这将返回一个string
,您尝试使用另一个string
来访问它,
data["encodings"]
因此出现错误。