我正在使用人臉識別并且代碼作業正常,但是當我停止代碼時,它會出現以下錯誤。
Traceback (most recent call last):
File "E:\FYP(STUDENT)\STUDENT\Main.py", line 73, in <module>
encodecurFrame = face_recognition.face_encodings(imgS, facedetectionFrame)
File "E:\FYP(STUDENT)\STUDENT\lib\site-packages\face_recognition\api.py", line 214, in face_encodings
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
File "E:\FYP(STUDENT)\STUDENT\lib\site-packages\face_recognition\api.py", line 214, in <listcomp>
return [np.array(face_encoder.compute_face_descriptor(face_image, raw_landmark_set, num_jitters)) for raw_landmark_set in raw_landmarks]
KeyboardInterrupt
這是第 73 行
while True:
success, img = cap.read()
imgS = cv2.resize(img,(0,0),None, 0.25, 0.25)
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
facedetectionFrame = face_recognition.face_locations(imgS)
73 -> encodecurFrame = face_recognition.face_encodings(imgS, facedetectionFrame)
你們能告訴我問題可能是什么以及如何解決嗎
uj5u.com熱心網友回復:
這不是錯誤。它說您正在手動停止代碼或代碼正在從其Normal Flow停止。您可以使用此代碼,按下q代碼將停止:
while True:
success, img = cap.read()
imgS = cv2.resize(img,(0,0),None, 0.25, 0.25)
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
facedetectionFrame = face_recognition.face_locations(imgS)
encodecurFrame = face_recognition.face_encodings(imgS, facedetectionFrame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/488847.html
