OpenCV | imshow()弹出窗口图片未响应;无法显示图片

显示图像是 Opencv最基本的操作之一, imshow()函数可以实现该操作。如果使用过其他GUI框架背景,就会很自然地调用 ishow来显示一幅图像。但这个观点并不完全正确,因为图像确实会显示出来,但随即会消失。例如下面代码:

import cv2
color_img = cv2.imread('C://Users/Bandari/code/py/beauty1.jpg')
cv2.imshow('C://Users/Bandari/code/py/beauty1.jpg',color_img)

则会出现这种情况:无响应
在这里插入图片描述
下面的代码可保证显示视频时窗口上的帧可以一直进行更新。以下几行简单的代码可以显示一幅图像:

import cv2
color_img = cv2.imread('C://Users/Bandari/code/py/beauty1.jpg')
cv2.imshow('C://Users/Bandari/code/py/beauty1.jpg',color_img)
cv2.waitKey()
cv2.destroyAllWindows()

这样就可以正常显示:
在这里插入图片描述

show()函数有两个参数:显示图像的帧名称、要显示的图像本身。
调用 destroyWindows()函数可以释放由 OpenCV创建的所有窗口。

GitHub 加速计划 / opencv31 / opencv
216
19
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:10 天前 )
5c1c39af dnn: Tune CONV_NR_FP32 size for WASM #27773 We can see ~20% inference time reduction on local benchmark. The local benchmark includes face detection with res10_300x300_ssd_iter_140000_fp16.caffemodel and image classification with squeezenet.onnx . ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake 1 天前
5b1d3255 build: fix OpenBLAS cmake search 6 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐