python - 带有open cv python响应的索引错误数组
问题描述
运行对象检测系统 ubnutu 20.04 lts 时出现此错误
它开始运行并打印一些数组但随后立即发生错误任何帮助将不胜感激我使用的是opencv最新版本
[[1]
[1]] [[578 25 182 215]
[604 112 675 608]]
[[ 1]
[82]
[18]] [[657 277 623 443]
[953 16 309 442]
[636 258 644 461]]
Traceback (most recent call last):
File "/home/jason/Documents/PythonProjects/VoiceAssistant/ObjectDetection.py", line 31, in <module>
cv2.putText(img,classNames[classId-1].upper(),(box[0]+10,box[1]+30), IndexError: list index out of range
while True:
success,img = cap.read()
classIds, confs, bbox = net.detect(img,confThreshold=thres)
print(classIds,bbox)
if len(classIds) > 0:
for classId, confidence,box in zip(classIds.flatten(),confs.flatten(),bbox):
cv2.rectangle(img,box,color=(0,255,0),thickness=2)
cv2.putText(img,classNames[classId-1].upper(),(box[0]+10,box[1]+30),
cv2.FONT_HERSHEY_COMPLEX,1,(0,255,0),2)
解决方案
推荐阅读
- javascript - Javascript 似乎没有通过引用传递对象
- module - Discord.JS Purge.js 命令问题
- navigation - 如何在简单的 SwiftUI 应用中有效地使用导航链接?
- swift - 如何在 RxSwift 中累积组合两个序列?
- groovy - Significance of `@` in Groovy regex
- php - WooCommerce: Add for specific pages a custom button next to Add to Cart using WordPress Custom Fields
- asp.net-core - 警告“@(!isEditing || ...)”不是属性“禁用”的有效值?
- flutter - 我不能在颤振上使用 get 包
- python - pymysql中的多个内连接
- css - 使用主题 css 文件将其他代码嵌入到 Wordpress whitout