Cancel VideoCapture::open RTSP from an other thread [closed]
Hi all,
I'm developping a C++ application using Qt (5.12), OpenCv (4.1.0) and GStreamer on Ubuntu 18.04 I instanciate a VideoCapture object in a dedicaced thread, then I try to open a RSTP connection with a deconnected video camera. The timeout of VideoCapture::open("rtspsrc location=rtsp://...) is about 20 seconds. When I close my application, my main thread wait the open failed to close properly the GUI. 20 seconds are too long for a GUI. I think there are 2 solutions to solve my problem, but I don't manage to implement them... any help is appreciated :)
- Reduce the timeout, but it seems to be implemented in the interface (cv::CAP_GSTREAMER in my case), and need to compile opencv :(
- Cancel the open() from the main Thread, the best solution. I already tryed to call VideoCapture::release(), or to delete my object (desperate solution I know ^^'), but the open() doesn't exit before its timeout...
please avoid multithreading with opencv.
computer-vision programs also might not need a gui (or a human in the loop)
With a GUI application and lot of treatments, I don't have other solution that threading treatments. My application architecture can handle 2 sources (video camera or files). Each source (VideoCapture) is connected to 3 outputs (GUI / File (VideoWriter) / RTSP server). In the following diagram, the [] represent a thread : [Source] => [Publisher (process copy)] => [Outputs file] / [RTSP server] / [GUI (rendered by the main thread (qml)] This architecture works fine, but I still have my problem to close the VideoCapture during the open() step.
let's note the absence of any actual computer-vision task
Well seen @berak, it's the next step of my developpment :). For now, I just need to display/record/forwad a video.