Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is there a python API equivalent of cvGetWindowHandle()?

Hi everyone, I've been searching for a solution to this common problem that myself and others seem to have when closing a window from a feed by clicking one the window's "X" button instead of pressing a key that gets handled by openCV.

A lot of routines involve capturing, processing, and displaying the frame inside of a while loop. Once a user presses a certain key, using cv2.waitKey allows them to enter an if statement that then closes all windows and breaks out of the routine. The problem occurs when a person clicks the "X" button on the iwindow instead of pressing whatever user-defined key to exit. I've been able to get around the program crashing when they click the X button by repeatedly showing the image in the while loop, but it would be great and more intuitive to just click the X button and be done with the routine.

Is there any equivalent python command similar to cvGetWindowHandle() or any kind of workaround to this issue? Your input is always appreciated. Thanks!