前几天在做视频目标检测时还是好好的,不知道是不是后面添加了环境还是什么原因,今天检测就出现了下面的错误:
Traceback (most recent call last):
File "predict.py", line 107, in <module>
cv2.imshow("video",frame)
cv2.error: OpenCV(4.6.0) /io/opencv/modules/highgui/src/window.cpp:1267: 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'
应该是opencv出了问题
解决方法:
我之前是用pip install opencv-python安装的,所以得先卸载
pip uninstall opencv-python
然后安装
pip install opencv-contrib-python
然后运行问题就解决了!
查看了网上其他博主的解决方案:
参考链接:https://blog.csdn.net/weixin_43808708/article/details/108790093
https://blog.csdn.net/weixin_38130913/article/details/104604587