【问题标题】:How can I capture detected image by Yolov4如何捕获 Yolov4 检测到的图像
【发布时间】:2021-10-12 22:42:18
【问题描述】:

我想捕捉使用 YOLOv4 网络摄像头识别时识别的框。

所以我使用了这个代码。

import cv2
import detect as dt
from darknet import Darknet
from PIL import Image
vidcap = cv2.VideoCapture(0)
success, image = vidcap.read()
count = 0
m = Darknet('darknet/data/yolo-obj.cfg')
m.load_weights('darknet/backup/yolo-obj_30000.weights')
use_cuda = 1
m.cuda()
while success:
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    im_pil = Image.fromarray(image)
    im_pil = im_pil.resize((m.width, m.height))
    boxes = dt.do_detect(m, im_pil, 0.5, 0.4, use_cuda)
    result = open('Desktop/captureyolobox/capture%04d.jpg'%(count), 'w')
    for i in range(len(boxes)):
        result.write(boxes[i])
    count = count + 1
    success, image = vidcap.read()
    result.close()

我遇到过这个问题。我在网上冲浪以解决问题,但我找不到。你能帮帮我吗?

Traceback (most recent call last):

  File "yoloshort.py", line 2, in <module>

    import detect as dt

ImportError: No module named detect

【问题讨论】:

  • 它的意思是,您当前目录中没有 detect.py 文件或者您没有安装检测库,请检查您复制该代码的位置
  • 谢谢你的帮助我解决了这个问题:)

标签: python object-detection video-capture screen-capture yolov4


【解决方案1】:

你的意思是darknet.py中的detect_image吗?你可以查看你想要的darknet.py。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-21
    • 2018-05-11
    • 1970-01-01
    • 1970-01-01
    • 2016-07-04
    • 2016-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多