I am displaying live video from a camera using OpenCV in Python. This is the code:
capture = cv.CaptureFromCAM(0)
if capture:
cv.NamedWindow("Live Video", cv.CV_WINDOW_AUTOSIZE)
frame = cv.QueryFrame(capture)
if frame:
cv.ShowImage("Live Video", frame)
cv.WaitKey(0)
cv.DestroyWindow("Live Video")
Now, I can only close my video window by pressing “esc”, but nothing happens when I click on my window’s close “X” button. Is there a way to make that work?
OpenCV does not have this feature, and only handles key presses by default.
If you want to do this, you must use the handle of the window manager that creates your windows (GTK, QT, …).
This post describes a similar issue in case you use windows.
Let me know if not 😉