I'm trying to add a camera image showing component to an existing python program that shows multiple input in real time from various hardware devices.
To that end, I need to use openCV's imshow()
function on the main thread to show frames from separate frame capture and processing threads (since imshow()
doesn't work outside it).
From what I understand I can't use a while loop to do that, since the program would be stuck on it and everything else would not run. What could be a solution? I wondered about putting everything else on a separate thread (including the frame grab 'sub-threads') and keeping only imshow on the main one. But that doesn't seem right.
EDIT
The problem with the imshow()
function on the frame capture/display thread was apparently not adding a cv2.waitKey(1)
function. Not including that line causes the window to freeze even in the main thread.
I don't have rep enough to comment, so I am writing here. I think you can use simple ROS structure to publish frames as ros-topic then do what ever you want with different ros-nodes.