问题
cv2.imshow
显示图像时报错,无法显示图像
0%| | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/xxx/workspace/inference.py", line 380, in <module>
cv2.imshow('result', img)
cv2.error: OpenCV(4.8.0) /io/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'
貌似因为之前
pip3 install opencv-python-headless
安装后导致版本不一致了。
解决方案
pip3 uninstall opencv-python
pip3 install opencv-python-contrib
pip3 install opencv-python
参考引用
解决问题:If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then…‘cvShowImage‘