[ WARN:[email protected]] global D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('IMG/完成时间0.png'): can't open/read file: check file path/integrity
Traceback (most recent call last):
File "D:\Works\work\填补工单\测试找0.py", line 6, in
xin_zeng = pyautogui.locateOnScreen('IMG/完成时间0.png', grayscale=True) # 寻找图片
File "C:\Users\FMY\AppData\Local\Programs\Python\Python39\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper
return wrappedFunction(*args, **kwargs)
File "C:\Users\FMY\AppData\Local\Programs\Python\Python39\lib\site-packages\pyautogui\__init__.py", line 213, in locateOnScreen
return pyscreeze.locateOnScreen(*args, **kwargs)
File "C:\Users\FMY\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 373, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
File "C:\Users\FMY\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 353, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
File "C:\Users\FMY\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 207, in _locateAll_opencv
needleImage = _load_cv2(needleImage, grayscale)
File "C:\Users\FMY\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 170, in _load_cv2
raise IOError("Failed to read %s because file is missing, "
OSError: Failed to read IMG/完成时间0.png because file is missing, has improper permissions, or is an unsupported or invalid format
主要是两个问题:
①路径的斜杠与反斜杠
②图片命名不能包含中文
我使用的pyautogui一直是没有问题的,但是加上pip install opencv-python 就会报错很奇怪,这下终于解决了。
参考:使用opencv读取图片时出现错误:cv2.error: OpenCV(4.4.0)解决办法_木泽锐的博客-CSDN博客使用opencv读取图片时出现错误:cv2.error: OpenCV(4.4.0)解决办法- 利用opencv对图像进行增强时出现如下错误:cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-k8sx3e60\opencv\modules\imgproc\src\resize.cpp:3929: error: (-215:Assertion failed) 原代码:百度出现的错误代码,https://blog.csdn.net/qq_43521500/article/details/108751507