【发布时间】:2020-10-27 05:13:43
【问题描述】:
我有代码:
import cv2
import matplotlib.pyplot as plt
import cvlib as cv
from cvlib.object_detection import draw_bbox
im = cv2.imread(r'C:\Users\james\OneDrive\Desktop\logos\normal.png')
bbox, label, conf = cv.detect_common_objects(im)
output_image = draw_bbox(im, bbox, label, conf)
plt.imshow(output_image)
plt.show()
它检测到图片中的大多数对象,但我希望能够从实时视频中制作它,我尝试使用 cap = cv2.VideoCapture(0) 但我无法让它工作。
【问题讨论】:
-
您必须提供更多关于它不工作的方式的信息。它会抛出错误吗?你得到一个完全黑色的图像吗?你试过视频文件吗?你的设置是什么?什么硬件?
-
嗨,我应该更具体地说明这个问题,我希望它是现场直播的,但我想如果我真的需要的话,我可以使用视频文件,这个代码上限 = cv2。 VideoCapture(0) while(True): ret, frame = cap.read() ## im = cv2.imread(r'C:\Users\james\OneDrive\Desktop\logos\imagetodetect.jpg') bbox, label, conf = cv.detect_common_objects(frame) output_image = draw_bbox(frame, bbox, label, conf) plt.imshow(output_image) plt.show() plt.clf() 当我运行它时它只显示一帧然后结束程序, 谢谢。我正在使用 3.5.0 python
-
srry 格式化无法正确格式化
-
drive.google.com/file/d/1dk9lP5iHGb0kzOK79ofmQuJDZ5HqvubN/… 驱动器中有文件可以查看,因此格式正确
-
感谢您的澄清。您能否将您的第一条评论放在后代问题中?
标签: python image matplotlib detection cv2