试试这个回答
http://code.opencv.org/issues/1751#note-4
(MSDN)中的这段话
The _CrtIsValidHeapPointer function is used to ensure that a specific memory address is within the local heap. The “local” heap refers to the heap created and managed by a particular instance of the C run-time library. If a dynamically linked library (DLL) contains a static link to the run-time library, then it has its own instance of the run-time heap, and therefore its own heap, independent of the application’s local heap. When _DEBUG is not defined, calls to _CrtIsValidHeapPointer are removed during preprocessing.
看了这段话稍微觉得有点意思了,我在程序中自己申请了本地堆,也有要生成动态连接库的DIB类,要连接c运行库,那么我的ColHistogram的实例必须动态生成,因为它在c运行库中没有对应的堆。比如我添加Cstring str;程序就不会有问题,但是我只知道CString是系统定义的,和c运行库有什么关系我就不清楚了。如果静态链接C运行库,那么,dll就要拥有一个独立于应用程序(调用它的exe)的本地堆(但是我的程序没有),如果没有定义_DEBUG,那么_CrtIsValidHeapPointer将被预处理器移除。大概就是这个样子,上面所说的很多东西我都不确定,只是现在的一种解释。
//////////////////////////我的代码//////////////////////////////
std::vector< std::vector<cv::Point> > contoursVec_temp;
cv::findContours(gray, contoursVec_temp, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE );
//////////////////////////////////////////////////////////////////
问题在contoursVec_temp会被findContours函数内部释放,但这是不许的,所以出错了吗?
怎么动态分配 contoursVec_temp呢?
请指教!