[英]Assertion failed in imread() function
I'm trying to do a simple template matching with openCV-python, but right in the beginning getting an error.我正在尝试用 openCV-python 做一个简单的模板匹配,但一开始就出错了。 I've run the following code:
我已经运行了以下代码:
import cv2 as cv
import numpy as np
haystackImg = cv.imread('fullImage.png', cv.IMREAD_UNCHANGED)
needleImg = cv.imread('diamond.png', cv.IMREAD_UNCHANGED)
result = cv.matchTemplate(haystackImg,needleImg, cv.TM_CCOEFF_NORMED)
cv.imshow('result', result)
cv.waitKey() ```
...and I got this error: ...我收到了这个错误:
[ WARN:0@0.186] global D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('fullImage.png'): can't open/read file: check file path/integrity
[ WARN:0@0.195] global D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('diamond.png'): can't open/read
file: check file path/integrity ython39/python.exe "c:/U
Traceback (most recent call last):
File "[myFilePath]\starting.py", line 8, in <modd file: check file path/ule>
result = cv.matchTemplate(haystackImg,needleImg, cv.TM_CCOEFF_NORMED)
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\templmatch.cpp:588: error: (-215:Assertion failed) corr.rows <= img.rows +
templ.rows - 1 && corr.cols <= img.cols + templ.cols - 1 in function 'cv::crossCorr'
The confusing part of it, that I didn't even have a D: drive, and the module is searching for something on that.令人困惑的部分是,我什至没有 D: 驱动器,并且该模块正在其上搜索某些东西。 I reinstalled it, but it didn't help.
我重新安装了它,但它没有帮助。
The problem was, that my source path contained non ASCII characters such as á and é... Created a new location without any non ASCII characters and white-spaces, and it works fine now.问题是,我的源路径包含非 ASCII 字符,例如 á 和 é... 创建了一个没有任何非 ASCII 字符和空格的新位置,现在它工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.