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.
please check, if you're linking to debug dlls (ending in *.d.dll) in debug mode. also, if you link against "multithreaded-dll" c-runtime
I linked in MTd runtime before. Thanks