lmm_face_encoding = face_recognition.face_encodings(lmm_image)[0] IndexError:列表索引超出范围

时间:2018-03-21 08:41:09

标签: python python-3.x

import face_recognition
import cv2

input_movie = cv2.VideoCapture("ruangan1.mp4")
length = int(input_movie.get(cv2.CAP_PROP_FRAME_COUNT))
print()

fourcc = cv2.VideoWriter_fourcc(*'XVID')
output_movie = cv2.VideoWriter('output3.avi', fourcc, 30, (1920, 1080))

lmm_image = face_recognition.load_image_file("wajah_depan_syahdan.jpg")
lmm_face_encoding = face_recognition.face_encodings(lmm_image)[0]

known_faces = [
    lmm_face_encoding
]

我收到错误说:

lmm_face_encoding = face_recognition.face_encodings(lmm_image)[0]
IndexError: list index out of range

我该如何解决?

1 个答案:

答案 0 :(得分:0)

if (len( face_recognition.face_encodings(
image_to_be_matched))> 0):
   print("face found in image!")
   '''continue'''
else:
    print('Face Not found')
    '''Do Something Else or repeat capture'''


#I think this Will help You!