Ask Your Question

firbo's profile - activity

2014-06-22 21:26:40 -0600 commented question Problem using std::vector as a parameter in some opencv functions

I linked in MTd runtime before. Thanks

2014-06-20 22:05:45 -0600 asked a question 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.

2014-06-20 22:01:41 -0600 received badge  Editor (source)
2014-06-20 03:33:06 -0600 commented question Problem using std::vector as a parameter in some opencv functions

Just a little accident while editing

2014-06-20 03:27:17 -0600 asked a question 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.

So what can I do?