python - FasterRcnn 模型未显示边界框
问题描述
我试图在出现在屏幕上的人周围绘制边界框。但似乎,代码已经检测到框架中的人,但无法为其绘制边界框。
请帮我解决这个问题。
我正在使用这个模型,faster_rcnn_inception_resnet_v2_atrous_coco_2018_01_28
源代码
def draw_boxes(result,imgToDisplay,w,h):
#Draw bounding boxes onto the frame.
for box in result[0][0]: # Output shape is 1x1x100x7
conf = box[2] #box[2] = result[0][0][2] is a probability value
print("probability value : ",conf)
print("box[0] : ",box[0]) #Object found or not
print("box[1] : ",box[1]) #Object class
print("xmin : ", box[3])
print("ymin : ", box[4])
print("xmax : ", box[5])
print("ymax : ", box[6])
#In below code, w and h are height and width of image respectively
if conf >= 0.1:
xmin = int(box[3] * w)
ymin = int(box[4] * h)
xmax = int(box[5] * w)
ymax = int(box[6] * h)
cv2.rectangle(imgToDisplay, (xmin, ymin), (xmax, ymax), (0, 0, 255), 1)
cv2.imshow('Object_detection',imgToDisplay)
解决方案
推荐阅读
- angular - HTMLCollectionOf 缺少“NodeList”类型的以下属性
- c++ - 返回具有另一个类的数据成员的构造函数?出现转换错误?
- postgresql - 2020年AWS RDS公有证书更新准备(Postgres)
- angular - FontAwesome 未正确加载 Angular 元素
- javascript - 是否可以让 JQGrid Tree 使用 OnSelectRow 展开节点
- amazon-s3 - AWS S3 中的跨账户文件访问
- python - 您将如何使用另一个包含列表的列表来订购包含列表的列表?
- vhdl - VHDL 中的 2:1 Mux - 信号不改变值
- apache-spark - 带有结构化流 protobuf 的 Apache Kafka
- java - 实现 Iterable 与实现 Iterator