网上复制了一个转直方图的代码 ,说来也奇怪, 用imshow 显示 图片在独立窗体内,不存在问题, 要注释掉这段代码就出现了下边的错误. 网上查了查,原来是程序中 有个std::vector<cv::Mat> ColorChannels;写法出了问题
//char OUTPUT_T[] = "histogram demo";
//imshow(OUTPUT_T, histImage);
报错:
Microsoft Visual C++ Runtime Library --------------------------- Debug Assertion Failed! Program: ...workspace\FileConverter\FileHandler\x64\Debug\FileHandler.exe File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp Line: 980 Expression: __acrt_first_block == header For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. (Press Retry to debug the application) --------------------------- 中止(A) 重试(R) 忽略(I) ---------------------------
问题原因有人说:使用DLL的时候,问题可能在于不同的堆用于分配和释放 引起的。
网上找到一段英文按照他说的改了,没问题了
The following code does not give the assertion, I simply changed std::vector<cv::Mat> ColorChannels; to cv::Mat ColorChannels[3];. I think that my solution is quick and dirty and maybe the solution offered by iedoc is better (I did not test it).
把上边的
std::vector<cv::Mat> ColorChannels;换成 cv::Mat ColorChannels[3];.
问题解决
技术交流qq群:143280841