解决opencv中使用cv2.imshow不显示图片问题
opencv
OpenCV: 开源计算机视觉库
项目地址:https://gitcode.com/gh_mirrors/opencv31/opencv
·
在使用opencv中的cv2.imshow显示图片的时候总会出现如下错误:cv2.error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
1:查找了很多资料发现是在安装opencv的时候安装顺序出现了问题,于是执行下面代码,重新安装imshow就能成功显示图片了
pip uninstall opencv-python
pip uninstall opencv-contrib-python
pip install opencv-contrib-python
pip install opencv-python
二:模块冲突,卸载opencv-contrib-python,查看以下几种包之间依赖
大概率解决问题。
opencv-python: 只包含opencv库的主要模块. 一般不推荐安装.
opencv-contrib-python: 包含主要模块和contrib模块, 功能基本完整, 推荐安装.
opencv-python-headless: 和opencv-python一样, 但是没有GUI功能, 无外设系统可用.
opencv-contrib-python-headless: 和opencv-contrib-python一样但是没有GUI功能. 无外设系统可用
OpenCV: 开源计算机视觉库
最近提交(Master分支:2 个月前 )
6bc22ad5
fix(features2d): Correct pointer arithmetic in BRISK corner traversal 1 天前
fbd55043
catch _com_error exceptions to suppress debugger flooding #28073
Resolves: #27643
This PR fixes an issue where the Microsoft Media Foundation (MSMF) backend triggers repeated C++ exceptions (_com_error) during video capture. While these exceptions are often non-fatal "first-chance" exceptions, they cause the Visual Studio debugger to break execution repeatedly, making debugging difficulty and flooding the output window.
Changes
cap_msmf.cpp: Added try-catch blocks around critical COM interaction paths.
Updated SourceReaderCB::OnReadSample (Async callback) to catch _com_error.
Updated CvCapture_MSMF::grabFrame (Synchronous grab) to catch _com_error.
Added CV_LOG_WARNING to log the error message from the caught exception, ensuring that actual errors are still visible in the logs without crashing the application or halting the debugger.
Impact
Users debugging OpenCV applications on Windows with Visual Studio will no longer be interrupted by internal MSMF exceptions when using the default backend.
The application flow remains uninterrupted even if MSMF encounters transient internal errors.
1 天前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)