error: (-215:Assertion failed) _img.size().height <= _templ.size().height && _img.size().width <= _templ.size().width in function 'cv::matchTemplate'
时间: 2023-12-10 14:03:52 浏览: 315
这个错误是由于模板图像的大小大于了原始图像的大小,导致匹配失败所引起的。在使用 OpenCV 的模板匹配函数 `cv2.matchTemplate()` 时,需要保证模板图像大小不大于原始图像大小。您可以通过检查原始图像和模板图像的尺寸来解决这个问题。如果需要,可以对图像进行调整或者裁剪,以确保它们的大小一致。
相关问题
result = cv2.matchTemplate(input_image_gray, template_gray, cv2.TM_CCOEFF_NORMED) cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\templmatch.cpp:1175: error: (-215:Assertion failed) _img.size().height <= _templ.size().height && _img.size().width <= _templ.size().width in function 'cv::matchTemplate'是什么问题
这个错误表明,在使用matchTemplate函数进行模板匹配时,输入图像的高度大于了模板图像的高度。这是不合法的,因为模板图像必须小于等于输入图像。请确保您正确地设置了输入图像和模板图像,并确保模板图像小于等于输入图像。
error: (-215:Assertion failed) _src.dims() == 2 && _src.type() == CV_32FC3 in function 'cv::TonemapImpl::process'
This error message indicates that an assertion failed because the input image or matrix does not have two dimensions.
In OpenCV, most functions that operate on images or matrices expect them to have two dimensions, which typically represent the height and width of the image or matrix. If the input has a different number of dimensions, this assertion will fail and the program will terminate with this error message.
To fix this error, make sure that the input image or matrix has two dimensions by checking its shape or size. If necessary, reshape or resize the input to have two dimensions before passing it to the function.
阅读全文