在Windows运行cv2.imshow("demo", img)报错:
Traceback (most recent call last):
File "C:\Users\NUC\Desktop\ov_handbook\Chapter2\yolov5s_cls_ov_sync_infer_demo.py", line 45, in <module>
cv2.imshow("Demo",image)
cv2.error: OpenCV(4.7.0) 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'
解决办法:安装opencv-contrib-python
pip install opencv-contrib-python
搞定!