首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >lmm_face_encoding = face_recognition.face_encodings(lmm_image)[0] IndexError:列表索引超出范围

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

Stack Overflow用户
提问于 2018-03-21 16:41:09
回答 1查看 901关注 0票数 0
代码语言:javascript
复制
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
]

我得到的错误是:

代码语言:javascript
复制
lmm_face_encoding = face_recognition.face_encodings(lmm_image)[0]
IndexError: list index out of range

我怎么才能修复它?

EN

回答 1

Stack Overflow用户

发布于 2019-06-03 06:32:01

代码语言:javascript
复制
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!
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49401581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档