简体   繁体   English

运行后的命令 cv2.imshow()、waitKey()、destroyAllWindows() 关闭镜像后继续运行

[英]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.当我使用 imshow() function 运行并打开图像时,它运行正常并且图像打开,但即使我退出图像,单元格(突出显示)仍会继续运行并且不会停止(你可以看到一颗星)。 And when I run other commands, then still cell loads and do not run.当我运行其他命令时,仍然会加载单元格并且不运行。 I restarted the kernel but no change.我重新启动了 kernel 但没有任何变化。 Issue is only while running imshow() and the cell contents that the cell loads,.问题仅在运行 imshow() 和单元格加载的单元格内容时出现。 enter image description here在此处输入图像描述

Don't use any window/frame based code in jupyter notebook.不要在 jupyter notebook 中使用任何基于窗口/框架的代码。

The API documentation for cv2.waitKey() notes the following: cv2.waitKey() 的 API 文档说明了以下内容:

    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以下是有关如何使用它的一些详细信息: https://medium.com/@mrdatainsight/how-to-use-opencv-imshow-in-a-jupyter-notebook-quick-tip-ce83fa32b5ad

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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