Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python OpenCV(4.4.0)错误:-215:断言失败,但仅适用于直接保存到搜索文件夹中的图像_Python_Opencv - Fatal编程技术网

Python OpenCV(4.4.0)错误:-215:断言失败,但仅适用于直接保存到搜索文件夹中的图像

Python OpenCV(4.4.0)错误:-215:断言失败,但仅适用于直接保存到搜索文件夹中的图像,python,opencv,Python,Opencv,在我的程序中,我使用pyautogui和cv2 ... import pyautogui import cv2 ... 程序用图像扫描文件夹,并按以下方式保存: images = [file for file in os.listdir('img/images/') if file.endswith('.png')] 然后在for循环中搜索屏幕截图,查找列表中的所有图像: pos = imagesearcharea(i, images,im=screenshot) 这对于已经在给定文件夹

在我的程序中,我使用pyautogui和cv2

...
import pyautogui
import cv2
...
程序用图像扫描文件夹,并按以下方式保存:

images = [file for file in os.listdir('img/images/') if file.endswith('.png')]

然后在for循环中搜索屏幕截图,查找列表中的所有图像:

pos = imagesearcharea(i, images,im=screenshot)
这对于已经在给定文件夹中的图像非常有效

然而,当我试图通过截图添加新图像,然后在画图中打开它,然后选择一个小样本(大约50x25像素)。然后我剪切样本并将其粘贴到paint中的新文件(新文件比粘贴的样本小,因此paint中的“画布”会放大以适合大小)。 最后,我将图像保存在test.png文件夹中并运行程序。文件被添加到列表中,并且路径似乎正确。这幅画没有损坏。 之前的所有图片都可以正常工作,但是当它开始处理test.png的函数时,我得到以下错误:

。。。 在imagesearcharea中 res=cv2.matchTemplate(img_gray,template,cv2.TM_cceff_NORMED) cv2.error:OpenCV(4.4.0)C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-9d\U dfo3\OpenCV\modules\imgproc\src\templmatch.cpp:588:error:(-215:断言失败)corr.rows