Ask Your Question
0

OpenCV dnn multi stream

asked 2020-08-17 16:18:23 -0600

KyloEntro gravatar image

Hi,

I'm writting a program to detect object using OpenCV DNN with a pre-trained model like SSD Mobilenet or yolo v4. I want to connect several cameras to my program and do object detection.

I don't know what is the best approach to this problem. Can I have for example 20 threads which get frames from different cameras and each in turn give the frame to a single opencv dnn object to do detection (use queue to store frame to analyse) ? OR Can I instanciate 20 detection objects for each camera and do detection when frame is available. So potentially, I can have 20 detections at the same time.

Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-08-18 01:24:36 -0600

berak gravatar image

updated 2020-08-18 01:34:50 -0600

I want to connect several cameras to my program and do object detection.

you'll soon find out the limits for this, as an usb2 hub can handle more than 1 camera only if you reduce the resolution (you'll need special hardware to handle 20 cams)

Can I have for example 20 threads which get frames from different cameras and each in turn give the frame to a single opencv dnn object

NO. networks cannot be shared between threads.

but you could collect your frames from different threads in a queue and send "batches" of images into the dnn

OR Can I instanciate 20 detection objects for each camera

means 20 times the resources (memory / GPU / CPU) this quickly goes through the roof ;(

edit flag offensive delete link more

Comments

1

Hi, Thanks for your answer.

For camera connexion, I use RTSP, I tried to connect to 30 cameras by using rtsp.

So, for my problem, the best approach is to use 1 thread for detection and 1 thread per camera and send the frame into the detection thread ?

KyloEntro gravatar imageKyloEntro ( 2020-08-18 01:57:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-08-17 16:18:23 -0600

Seen: 594 times

Last updated: Aug 17 '20