Hello dear community! I am porting some old opencv code from v.2.4.1 to v.4.8.1 and i have stucked with cv::VideoCapture get frames from two separate threads and two different cameras (in v.2.4.1 it works like a charm), i didn’t change any code, just changed version of openCV in my project (VS 2022, Windows).
Here is my code, i run it in two separate threads:
For test purpose i use the same camera from my laptop, it has index = 0, in v.2.4.1 it work without problems i can see a videocapture in two different windows from one camera., but in v.4.8.1 i can see a videocapture only in one window, besides if i start and stop the program it can be “window1” or “window2” any time it different, but never in two windows simultaneosly
I completely agree, could you please suggest any solution ? You mean that i cannot use anymore two different instance of cv::Videocapture with the same camera ID?
sure it’s possible, but opencv won’t help, because that is not opencv’s purpose. you should use multithreading but sensibly.
you should capture in one thread, then distribute every frame to each consumer.
if the consumers can’t keep up with production, you’ll have to know some computer science to coordinate that stuff. this would necessarily require dropping frames.
I just described how to read from one camera and then distribute that same frame to multiple consumers, in custom code. you should see that nothing prevents this.