Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Are there specific times when cv2.waitKey() is required?

So I've been playing around with various ideas for capturing some webcam feeds, and I am finding that I get varied results (some good some bad) by placing cv2.waitKey() functions in various places within my code.

I know that it is typically used to capture keyboard input, but I also read that cv2.waitKey() 'performs various tasks' (I'm paraphrasing as I don't remember the quote). Are there rules for when this function is required and / or when it is recommended? If so, can anyone point me to them?

(For instance) I asked in another question about why a loop of alternating frames from 2 webcams wasn't working... This evening, I got it working by adding a cv2.waitKey(1) after the .read() function and then after the .imshow() function. I tried different timings and different placements with varied (seemingly inconsistent) results.

Thank you very much! J

click to hide/show revision 2
retagged

updated 2014-10-02 00:48:03 -0600

berak gravatar image

Are there specific times when cv2.waitKey() is required?

So I've been playing around with various ideas for capturing some webcam feeds, and I am finding that I get varied results (some good some bad) by placing cv2.waitKey() functions in various places within my code.

I know that it is typically used to capture keyboard input, but I also read that cv2.waitKey() 'performs various tasks' (I'm paraphrasing as I don't remember the quote). Are there rules for when this function is required and / or when it is recommended? If so, can anyone point me to them?

(For instance) I asked in another question about why a loop of alternating frames from 2 webcams wasn't working... This evening, I got it working by adding a cv2.waitKey(1) after the .read() function and then after the .imshow() function. I tried different timings and different placements with varied (seemingly inconsistent) results.

Thank you very much! J