std::vector of cv::Mat causing memory corruption
I am using opencv_contrib's ximgproc moule's structural edge detector's code in my visual studio project . But it giving _CrtIsValidHeapPointer(pUserData) error expression . With some debugging I realized that Actually the error is caused when a function getFeatures defined in structured_edge_detector.cpp tries to push cv::Mat in a std::vector as shown below
virtual void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad,
const int shrink, const int outNum, const int gradNum) const
{
cv::Mat luvImg = rgb2luv(src);
std::vector <cv::Mat> featureArray;
cv::Size nSize = src.size() / float(shrink);
split( imresize(luvImg, nSize), featureArray );
CV_INIT_VECTOR(scales, float, {1.0f, 0.5f});
for (size_t i = 0; i < scales.size(); ++i)
{
int pSize = std::max( 1, int(shrink*scales[i]) );
}
mixChannels(featureArray, features, fromTo);
}
Please tell me what is the reason of such fault in program and any possible solution. My Opencv version is 2.4.10 so I am actually using the ximgproc's structured edge detector's code within my project.
Thanks
ohh, you again ;9
can you add some lines of test code ? (might be another buffer overrun due to weird image size or such)
also check, if you strictly use opencv debug libs in debug build, and release ones in release (since mixing them produces similar errors)