Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem using std::vector as a parameter in some opencv functions

VS2013/Windows8.1/opencv 2.4.9/debug mode

std::vector goes well in other places but once I use it as a parameter of an openCV function, it will end in assertion failed says"File:...\dbgheap.c line:1424 Expression:_pFirstBlock == pHead" Switch to release mode will solve this problem but the data in the vector will automatically and randomly change.

Even a very simple codepiece like this will go wrong

void test(Mat src)

{ vector<mat> srcPlanes; split(src, srcPlanes); //assertion failed here }

but this will work

void test(Mat src)

{ vector<mat> srcPlanes; split(src, srcPlanes); srcPlanes.push_back(Mat()); srcPlanes.push_back(Mat()); srcPlanes.push_back(Mat()); }

Same problem in some other opencv functions when calling the destructor,for example, findCountours

void test(Mat src)

{ vector<vector<point>> countours; findContours(src, countours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); //assertion failed here } If I manually change the adress in countours._mylast in debugging (for exsample,from 0x0034e910 to 0x0034e908,the size of the vector will decrease by one),then it will work.

Problem using std::vector as a parameter in some opencv functions

VS2013/Windows8.1/opencv 2.4.9/debug mode

std::vector goes well in other places but once I use it as a parameter of an openCV function, it will end in assertion failed says"File:...\dbgheap.c line:1424 Expression:_pFirstBlock == pHead" Switch to release mode will solve this problem but the data in the vector will automatically and randomly change.

Even a very simple codepiece like this will go wrong

void test(Mat src)

{ vector<mat> {

vector<Mat> srcPlanes;
  split(src, srcPlanes);

//assertion failed here here

}

but this will work

void test(Mat src)

{ vector<mat> srcPlanes; split(src, srcPlanes); srcPlanes.push_back(Mat()); srcPlanes.push_back(Mat()); srcPlanes.push_back(Mat()); }

Same problem in some other opencv functions when calling the destructor,for example, findCountours

void test(Mat src)

{ vector<vector<point>> countours; findContours(src, countours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); //assertion failed here } If I manually change the adress in countours._mylast in debugging (for exsample,from 0x0034e910 to 0x0034e908,the size of the vector will decrease by one),then it will work.

Problem using std::vector as a parameter in some opencv functions

VS2013/Windows8.1/opencv 2.4.9/debug mode

std::vector goes well in other places but once I use it as a parameter of an openCV function, it will end in assertion failed says"File:...\dbgheap.c line:1424 Expression:_pFirstBlock == pHead" Switch to release mode will solve this problem but the data in the vector will automatically and randomly change.

Even a very simple codepiece like this will go wrong

void test(Mat src)

{

vector<Mat> srcPlanes;

split(src, srcPlanes);

//assertion failed here

}

but this will work

void test(Mat src)

{ vector<mat> {

vector<Mat> srcPlanes;
  split(src, srcPlanes);
  srcPlanes.push_back(Mat());
  srcPlanes.push_back(Mat());
  srcPlanes.push_back(Mat());

}

Same problem in some other opencv functions when calling the destructor,for example, findCountours

void test(Mat src)

{ vector<vector<point>> {

vector<vector<Point>> countours;
  findContours(src, countours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

//assertion failed here here

} If I manually change the adress in countours._mylast in debugging (for exsample,from 0x0034e910 to 0x0034e908,the size of the vector will decrease by one),then it will work.