Connect several cameras openCV python

asked 2020-08-20 08:59:18 -0500

KyloEntro gravatar image

updated 2020-08-20 09:16:52 -0500


I want to connect to 30 cameras at the same time in my python program. If I execute 30 times a simple python script which connects to a rtsp camera and do .read(), I have no problem.

But, if I create 30 threads in my python program, some thread as delay and then crash. It is because of python GIL and my processor core is not to fast to deal all the thread sequentially ...

So I don't know how to deal with it... May be I could use multiprocessing but how can I share and image between my processus. Or use C++ ?

edit retag flag offensive close merge delete


Since python is an "interpreted" programming language, you would achieve better performance using C++ instead.

dbots94 gravatar imagedbots94 ( 2020-08-20 10:38:26 -0500 )edit

(Of course, a program should not crash just due to delays or number of threads. Delays can be handled and threads orhestrated.)

mvuori gravatar imagemvuori ( 2020-08-21 04:14:06 -0500 )edit

post your code. provide everything required to run it and demonstrate the problem you are describing. we will not speculate. as a rule of thumb, python IS capable of decent multithreading results. you just have to know what to do, and what not to do.

crackwitz gravatar imagecrackwitz ( 2020-08-22 16:56:03 -0500 )edit

python being interpreted is absolutely irrelevant to the matter at hand. network I/O and video codecs all happen in compiled machine code. python is the glue logic on top of that.

crackwitz gravatar imagecrackwitz ( 2020-08-22 16:57:57 -0500 )edit