我确实使用Yolo-V4进行对象检测,该检测仅在一个相机上检测。但是现在我需要同时使用50张摄像头进行对象检测。该怎么办?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论