我确实使用Yolo-V4进行对象检测,该检测仅在一个相机上检测。但是现在我需要同时使用50张摄像头进行对象检测。该怎么办?

发布于 2025-02-05 20:13:13 字数 744 浏览 2 评论 0原文

Python Yolo V4算法用于对象检测

假设我有50个摄像机,我需要在所有50个摄像机中进行对象检测。它不应该串联运行。所有50个都应并行运行。如何做。实时目的。我尝试了多线程和处理,但我对此非常糟糕。我完全是Python的初学者,这对我来说似乎很难。

我知道我们没有一个可以检查50个相机,因此我创建了一个路径变量,其中指定了50张图像的位置。只需要并行运行50张图像以进行对象检测

import os, time
import cv2

coco_classes = ["car", "plate", "motorcycle"]

net = cv2.dnn.readNet("custom.weights", "custom.cfg")
model = cv2.dnn_DetectionModel(net)
model.setInputParams(size=(416, 416), scale=1 / 255, swapRB=True)

path = './img/'

for fn in os.listdir(path):
    image = cv2.imread(path + fn)

    t = time.time()
    c, v, b = model.detect(image, 0.2, 0.4)
    t = time.time() - t

    c = [coco_classes[x] for x in c]
    print('{}ms : '.format(int(t * 1000)), list(zip(c, v)))```


python yolo v4 algo for object detection

assume I have 50 cameras, I need to do object detection in all 50 cameras. It shouldn't run in series. all 50 should run in parallel. how to do this. for Realtime purpose. I tried multithreading and processing but I am very very bad at it. I am complete beginner to python and this seems very hard for me.

I know none of us have 50 camera to check so I created a path variable where location of 50 images are specified. just need to run 50 images in parallel for object detection

import os, time
import cv2

coco_classes = ["car", "plate", "motorcycle"]

net = cv2.dnn.readNet("custom.weights", "custom.cfg")
model = cv2.dnn_DetectionModel(net)
model.setInputParams(size=(416, 416), scale=1 / 255, swapRB=True)

path = './img/'

for fn in os.listdir(path):
    image = cv2.imread(path + fn)

    t = time.time()
    c, v, b = model.detect(image, 0.2, 0.4)
    t = time.time() - t

    c = [coco_classes[x] for x in c]
    print('{}ms : '.format(int(t * 1000)), list(zip(c, v)))```


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文