简体   繁体   中英

The commands cv2.imshow(), waitKey(), destroyAllWindows() after running continues to run even after closing the image

when I run and open the image using imshow() function, it runs fine and image opens but the cell (highlighted) continues to run and does not stop(u can see a star) even though I exit the image. And when I run other commands, then still cell loads and do not run. I restarted the kernel but no change. Issue is only while running imshow() and the cell contents that the cell loads,. enter image description here

Don't use any window/frame based code in jupyter notebook.

The API documentation for cv2.waitKey() notes the following:

    This function is the only method in HighGUI that can fetch and handle events, so it needs to be called periodically for normal event processing unless HighGUI is used within an environment that takes care of event processing.

So, it just hangs.

Here's some details on how to use it: https://medium.com/@mrdatainsight/how-to-use-opencv-imshow-in-a-jupyter-notebook-quick-tip-ce83fa32b5ad

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM