stores cv::Mat into a std::vector
i'am trying to write many functions computing gradient with deferent kernels which return a vector of Mat object here one exemple :
std::vector<cv::Mat> histogram::SobelDirections(cv::Mat &frame){
Mat vectMat;
Mat Sx;
cv::Sobel(frame, Sx, CV_32F, 1, 0, 3);
Mat Sy;
cv::Sobel(frame, Sy, CV_32F, 0, 1, 3);
imshow("x", mat2gray(Sx));
imshow("y", mat2gray(Sy));
vectMat.push_back(Sx);
vectMat.push_back(Sy);
return vectMat;
}
i get this , any help would be appreciated
Program: C Windows system321MSVCP110D. dll
File: C:\Program Files icrosoft Visual Studio Include Vector Line: 1124
Expression: vector subscript out of range
here main code
cv::Mat mat2gray(const cv::Mat& src)
{
Mat dst;
cv::normalize(src, dst, 0.0, 255.0, cv::NORM_MINMAX, CV_8U);
return dst;
}
int main(int argc, char* argv[])
{
Mat image =Mat::zeros(Size(320, 240), CV_8UC1);
circle(image, Point(160, 120), 80, Scalar(255, 255, 255), -1, CV_AA);
imshow("x", mat2gray(SobelDirections(frame).at(0));
imshow("y", mat2gray(SobelDirections(frame).at(1));
return 0;
}
unlikely, that it happens in the code you show, maybe we need to see, where you use that vector
i will edit the question
sorry, it was in your function, missed it ;)