图像金字塔的模糊图像-矢量下标超出范围 我尝试加载图像,计算图像金字塔(保存每个图像),然后用C++中的OpenCV 3.2模糊金字塔的每个图像。当我运行我的程序时,我收到错误:
向量行:1740表达式:向量下标超出范围 这是我的密码:图像金字塔的模糊图像-矢量下标超出范围 我尝试加载图像,计算图像金字塔(保存每个图像),然后用C++中的OpenCV 3.2模糊金字塔的每个图像。当我运行我的程序时,我收到错误:,c++,image,opencv,vector,C++,Image,Opencv,Vector,向量行:1740表达式:向量下标超出范围 这是我的密码: #include "stdafx.h" #include <opencv2/highgui/highgui.hpp> #include <opencv2/xfeatures2d.hpp> #include <iostream> #include <opencv2/shape/shape.hpp> using namespace std; using namespace cv; using
#include "stdafx.h"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <iostream>
#include <opencv2/shape/shape.hpp>
using namespace std;
using namespace cv;
using namespace cv::xfeatures2d;
int main(int argc, char** argv)
{
// Read the image
Mat img_1;
img_1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
// Build an image pyramid and save it in a vector of Mat
vector<Mat> img_1_pyramid;
int pyramid_octaves = 3;
buildPyramid(img_1, img_1_pyramid, pyramid_octaves);
/* void cv::buildPyramid (InputArray src, OutputArrayOfArrays dst, int
maxlevel, int borderType = BORDER_DEFAULT) */
// Initialize parameters for the first image pyramid
vector<Mat> reduced_noise_1;
blur(img_1_pyramid[0], reduced_noise_1[0], Size(3,3));
/* void cv::blur (InputArray src, OutputArray dst, Size ksize, Point
anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)*/
return 0;
}
我们需要一个电话。例如,
buildPyramid
的声明。它可能没有通过引用接收向量。我对opencv了解不多,但当您调用blur
,减少的噪声\u 1[0]
超出范围,因为该向量为空。因为你实际上传递的是一个不存在的对象,而不是向量本身,所以函数不能做任何事情来改变向量的大小。
String::String(const char* s)
: cstr_(0), len_(0)
{
if (!s) return;
size_t len = strlen(s); // Here appears the error (only in German;))
memcpy(allocate(len), s, len);
}