复制步骤
1:通过tf_text_graph生成配置文件更快_rcnn.py公司在
python tf_text_graph_更快_rcnn.py公司--输入冻结推理_图形.pb--配置管道.config--输出速度更快_旧版.pbtxt在
冻结推理_图形.pb以及管道.config文件是解压后的吗
2:通过示例代码检测对象
import cv2 as cv
cvNet = cv.dnn.readNetFromTensorflow('tensorflow/faster_rcnn_inception_resnet_v2_atrous_oid.pb', 'tensorflow/faster_rcnn_inception_resnet_v2_atrous_oid.pbtxt')
img = cv.imread('traffic_jam.jpg')
rows = img.shape[0]
cols = img.shape[1]
cvNet.setInput(cv.dnn.blobFromImage(img, size=(300, 300), swapRB=True, crop=False))
cvOut = cvNet.forward()
for detection in cvOut[0,0,:,:]:
score = float(detection[2])
if score > 0.1:
left = detection[3] * cols
top = detection[4] * rows
right = detection[5] * cols
bottom = detection[6] * rows
cv.rectangle(img, (int(left), int(top)), (int(right), int(bottom)), (23, 230, 210), thickness=2)
cv.imshow('img', img)
cv.waitKey()
结果
tensorflow算法在this page上的检测结果
虽然仍有很多车辆无法检测,但与opencv的api相比,检测结果有较大差异
编辑:结果检测到的ssd_mobilenet_v1_coco,效果好得多,我猜opencv dnn模块不能很好地与我发布的模型一起工作?在
编辑2:ssd检测代码
^{pr2}$
300x300的输入大小不正确,因为
^{pr2}$pipeline.config
具有以下预处理指令:这意味着你必须保持图像比例。尝试处理原始帧(它有800x600):
包含置信阈值
^{4}$0.3
和pipeline.config
修改的输出here相关问题 更多 >
编程相关推荐