pyrDown 错误
Error with pyrDown
我是 OpenCV 的新手,我正在实施模板匹配的分层搜索,并且在一个步骤中,我需要对图像进行下采样。但是,我收到了注意到的错误。
另一点是当我注释掉第一个pyrDown
时,它适用于第二个,第一个pyrDown
产生错误,但我不知道为什么。有人,请帮我理解为什么会这样。
Mat sampled_image,sampled_reference;
GaussianBlur( prev_image , filtered_image , Size( 5, 5 ), 0 ,0 );
GaussianBlur(prev_reference, filtered_reference, Size(5,5), 0, 0);
pyrDown( filtered_image, sampled_image, Size(filtered_image.rows/2 , filtered_image.cols/2));
pyrDown( filtered_reference, sampled_reference, Size(filtered_reference.rows/2 , filtered_reference.cols/2));
image_array.push(sampled_image); // level 1 image LEVEL 1 IMAGE
reference_array.push(sampled_reference); // level 1 reference
prev_image = sampled_image;
prev_reference= sampled_reference;
抛出错误:
Width = 480 Height= 300 (of the filtered_image )
OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0 && std::abs(dsize.width*2 - ssize.width) <= 2 && std::abs(dsize.height*2 - ssize.height) <= 2) in pyrDown_, file C:\opencv-3.2.0\source\modules\imgproc\src\pyramids.cpp, line 873
terminate called after throwing an instance of 'cv::Exception' what(): C:\opencv-3.2.0\source\modules\imgproc\src\pyramids.cpp:873: error: (-215) ssize.width > 0 && ssize.height > 0 && std::abs(dsize.width*2 - ssize.width) <= 2 && std::abs(dsize.height*2 - ssize.height) <= 2 in function pyrDown_
由于不知道两张图片的尺寸,我无法确定,但我感觉你的参考图片是正方形的。
OpenCV pyrdown 文档(它适用于 opencv 2.4,但是你从 3.0 被重定向到那里,所以它应该存在。这是重要的部分:
|dstsize.width * 2 - src.cols| <= 2
|dstsize.height * 2 - src.rows| <= 2
这是失败的断言。我认为您已经交换了坐标,方形图像 (rows==cols) 可能不会引起注意,否则会失败。
尺寸应该是(宽,高)形式。宽度是列数,高度是行数。尝试这样做:
cv::pyrDown( input, output, Size( input.cols/2, input.rows/2 );
我是 OpenCV 的新手,我正在实施模板匹配的分层搜索,并且在一个步骤中,我需要对图像进行下采样。但是,我收到了注意到的错误。
另一点是当我注释掉第一个pyrDown
时,它适用于第二个,第一个pyrDown
产生错误,但我不知道为什么。有人,请帮我理解为什么会这样。
Mat sampled_image,sampled_reference;
GaussianBlur( prev_image , filtered_image , Size( 5, 5 ), 0 ,0 );
GaussianBlur(prev_reference, filtered_reference, Size(5,5), 0, 0);
pyrDown( filtered_image, sampled_image, Size(filtered_image.rows/2 , filtered_image.cols/2));
pyrDown( filtered_reference, sampled_reference, Size(filtered_reference.rows/2 , filtered_reference.cols/2));
image_array.push(sampled_image); // level 1 image LEVEL 1 IMAGE
reference_array.push(sampled_reference); // level 1 reference
prev_image = sampled_image;
prev_reference= sampled_reference;
抛出错误:
Width = 480 Height= 300 (of the filtered_image )
OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0 && std::abs(dsize.width*2 - ssize.width) <= 2 && std::abs(dsize.height*2 - ssize.height) <= 2) in pyrDown_, file C:\opencv-3.2.0\source\modules\imgproc\src\pyramids.cpp, line 873
terminate called after throwing an instance of 'cv::Exception' what(): C:\opencv-3.2.0\source\modules\imgproc\src\pyramids.cpp:873: error: (-215) ssize.width > 0 && ssize.height > 0 && std::abs(dsize.width*2 - ssize.width) <= 2 && std::abs(dsize.height*2 - ssize.height) <= 2 in function pyrDown_
由于不知道两张图片的尺寸,我无法确定,但我感觉你的参考图片是正方形的。
OpenCV pyrdown 文档(它适用于 opencv 2.4,但是你从 3.0 被重定向到那里,所以它应该存在。这是重要的部分:
|dstsize.width * 2 - src.cols| <= 2
|dstsize.height * 2 - src.rows| <= 2
这是失败的断言。我认为您已经交换了坐标,方形图像 (rows==cols) 可能不会引起注意,否则会失败。
尺寸应该是(宽,高)形式。宽度是列数,高度是行数。尝试这样做:
cv::pyrDown( input, output, Size( input.cols/2, input.rows/2 );