1 year ago

#335397

test-img

tobiasBora

OpenCV: control video playback with both keyboard and mouse

I'd like to be able to play a video (that automatically stops at some fixed frames), and I want to be able to play/stop either using keyboard or mouse. However, it seems that opencv does not provide a function to wait both a keyboard event or a mouse event. I saw there exists a function setMouseCallback but I'm not sure how to use it to make sure that I don't have any conflicts between the keyboard and the mouse. Am I supposed to create a thread that receive messages from both the mouse and the keyboard, or is there something simpler? Otherwise, is there any more suited library to play/seek/stop a video precisely on a given frame?

EDIT I tried to implement a solution based on threads, and I do action = self.queue.get() instead of cv2.waitKey(...), but then nothing is displayed on screen. Also, if I do cv2.waitKey(1) before, I get an empty frame, and the cv2.waitKey located in other threads does not detect any keypress...

python

opencv

user-interface

video

playback

0 Answers

Your Answer

Accepted video resources