Open sato-cloudian opened 8 years ago
@sato-cloudian thank you for the report. It seems indeed that the while loop has no case for exiting, by example by pressing ESC. By hitting CTRL+C it seems you are interrupting the program, but the destructor of the camera object is likely not called anymore.
@JoeHowse any suggestions on how to cleanly fix this in python?
We can solve this with cv2.waitKey function. For reference, please follow this tutorial http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html
:+1: I will add the suggested fix!
@JoeHowse and @sato-cloudian could you both check if the fix https://github.com/OpenCVBlueprints/OpenCVBlueprints/commit/513e6963b5ab4443643524f794460fbf48cc24b8 suits your guys needs?
Thanks for the issue report and suggestions. @sato-cloudian Which camera and which operating system are you using?
As of OpenCV 3.1.0, cv2.waitKey seems to be broken. It always returns -1. (I have just tested on Mac 10.11 and Windows 7 with a basic script that just runs cv2.waitKey in a loop.)
Moreover, cv2.waitKey(tMillisecs) will time-out and miss any input that happens beyond the next tMillisecs milliseconds. Thus, it is ineffective in a loop that contains other long-running statements such as time.sleep(tSecs).
For now, I am reverting the change and re-opening the issue.
@JoeHowse I tried Canon PowerShot G9 on my Ubuntu 14.04.3 box. But I use Mac as well for demonstration purpose. And I use OpenCV 3.1(master) because I want to deploy Caffe to classify a detected object with our trained convolutional neural network.
Anyway, thanks for your considerations. Let me know if you come up with a good idea. For the time being, I just move ahead.
Hi,
After terminating set_motion_trap.py by interrupting with Ctrl+C, my camera stays busy, and won't respond with the following error.
After manually plug it out and in, it starts responding again.
Is there anyway to cleanly terminate the program? Or anything wrong?
Thanks.