from pathlib import Path
import cv2
img_file = Path(r"1000000.jpg")
print("Image is exist ? ",img_file.exists())
if img_file.exists():
img = cv2.imread(str(img_file))
cv2.namedWindow("input image")
cv2.imshow("input image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\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’
这些报错基本都是版本上的问题,更新一下
pip install opencv-contrib-python -U