python
import cv2
# 检查版本
print(cv2.__version__)
# 加载一张图片(确保你有一个名为'test.jpg'的文件在当前目录)
image = cv2.imread('C:\\test1.jpg')
# 显示图片
cv2.imshow('image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2意思是opencv c++ o(* ̄︶ ̄*)o
建议使用Anaconda
这段代码报错,显示
cv2.imshow('image', image)
cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1301: 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'
在你觉得环境配置没问题的情况下,可以尝试以下办法处理下:
卸载 pip uninstall opencv-contrib-python
安装 pip install opencv-contrib-python