waitkey(1) freezes display output when previewing in multiple threading
I'm using OpenCV(4.1.2) with ubuntu(18.04), and built with GTK support. I need to preview more than one video(actually 2) in multiple threading. It means imshow() will be called in every thread that the application created. I knew that waitKey(ms) also needs to be called following by imshow().
My question is all 2 display outputs would be frozen when the application runs for a while. And then some time costed for search the solution. and someone said that What's happening is that you're abusing some feature of OpenCV that doesn't support running in a multi-threaded environment. https://stackoverflow.com/questions/4....
He suggests naming a new window before calling imshow(), or add thread mutex to control competition between threads.
I tried all the above but no any could give help. Then waitkey(ms) removed inadvertently, and the problem never occurred again. But I really do not understand why calling waitKey can effect it. Here's my code
RECEIPE FOR DESASTER.
all opencv gui functions have to stay in the main thread.
and you probably don't need multithreading at all, and only introduced that problem, because your "flowchart" was too naive.
it's perfeectly ok, to play multiple videos from a single thead