索引器错误:列表索引超出范围/Facen

2024-10-04 11:28:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在试用一个使用Facenet算法的人脸识别程序。一切都很好,很好的识别,但程序得到退出时,我移动我的头快速与这个错误。你知道吗

Traceback (most recent call last):
  File "vf.py", line 122, in <module>
    if HumanNames[best_class_indices[0]] == H_i:
IndexError: list index out of range




  for H_i in HumanNames:
       if HumanNames[best_class_indices[0]] == H_i:
       result_names = HumanNames[best_class_indices[0]]
       cv2.putText(frame, result_names, (text_x, text_y),  cv2.FONT_HERSHEY_COMPLEX_SMALL,1, (0, 0, 255), thickness=1, lineType=2)

Tags: textin程序算法ifnames错误result
1条回答
网友
1楼 · 发布于 2024-10-04 11:28:08

似乎HumanNames中没有存储任何值,如果是这样的话,那么访问列表中的第一项将抛出一个错误是有意义的。你知道吗

首先,您应该检查人名数组的大小,在调试过程中,添加以下行:

print(len(HumanNames))
# The rest of the code from the example....

相关问题 更多 >