简体   繁体   English

调试断言失败-DirectShow过滤器调用OpenCV函数-仅发布模式

[英]Debug Assertion Failed - DirectShow Filter calling OpenCV Function - Release mode only

I am programming a DirectShow Filter that detects objects with an OpenCV HaarcascadeClassifier . 我正在编写一个DirectShow筛选器,以使用OpenCV HaarcascadeClassifier检测对象。 It is working fine in Debug mode but not in Release mode and I'm not sure whether there is an memory leak in the OpenCV function (VC 2010 binary of opencv_249 libs) or whether there is something wrong with my project (settings). 它在“调试”模式下可以正常工作,但在“发布”模式下却不能,并且我不确定OpenCV函数(opencv_249 libs的VC 2010二进制文件)中是否存在内存泄漏,或者我的项目(设置)是否有问题。

I am loading the filter in GraphStudio, a tool to build a DirectShow FilterGraph easily. 我正在GraphStudio中加载过滤器,该工具可轻松构建DirectShow FilterGraph。 I'm not sure whether there are assumptions about the filter DLL to be compiled in Debug mode or not. 我不确定是否有关于在调试模式下编译过滤器DLL的假设。

I'm basically doing the following, after some preprocessing: 经过一些预处理后,我基本上在做以下工作:

std::vector<cv::Rect> objects;
mClassifier.detectMultiScale(inputGray,objects, 1.3);

for(unsigned int i=0; i<objects.size(); ++i)
{
    cv::rectangle(outputImage, objects[i], cv::Scalar(255,255,255));
}

So within the function block I am preprocessing, followed by the shown part of code and followed by writing the data to the DirectShow Buffer. 因此,在功能块中,我正在预处理,然后是代码的所示部分,然后将数据写入DirectShow Buffer。

If I use the DLL in Release mode, I get the following error message AFTER the whole function terminated (so probably somewhere else inside the DirectShow Filtergraph): 如果我使用的DLL在Release模式,我收到以下错误消息 ,整体功能终止(所以大概别的地方FilterGraph动态的DirectShow里面):

Debug Assertion Failed!

Program: C:\Program Files (x86)\Graphstudio\graphstudio.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Line: 52

Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

For information [...]

followed by a 跟一个

Debug Assertion Failed!

Program: C:\Program Files (x86)\Graphstudio\graphstudio.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Line: 1322

Expression: _CrtlsValidHeapPointer(pUserData)

When I comment mClassifier.detectMultiScale(inputGray,objects, 1.3); 当我评论mClassifier.detectMultiScale(inputGray,objects, 1.3); out, the filter doesn't crash. 出来,过滤器不会崩溃。 Though some things might be optimized away, I replaced the detectMultiScale call with a loop that randomly (previously seeded with time(NULL)) inserts cv::Rect objects into the vector. 尽管可能已经优化了一些东西,但我用一个循环替换了detectMultiScale调用,该循环随机地(以前用time(NULL)种子)将cv::Rect对象插入向量。 The filter does not crash and displays the random rectangles in the way I would assume. 筛选器不会崩溃,并按照我假定的方式显示随机矩形。

I've read that others have observed (valgrind) cv::CascadeClassifiert::detectMultiScale to produce memory leaks. 我已经读到其他人已经观察到(valgrind) cv::CascadeClassifiert::detectMultiScale产生内存泄漏。 And I've found a link where someone had a problem with detectSingleScale and some OpenCV committer marked it to be fixed ( http://code.opencv.org/issues/2628 ). 而且我发现了一个链接,其中有人对detectSingleScale遇到了问题,一些OpenCV提交者将其标记为已修复( http://code.opencv.org/issues/2628 )。

Questions: 问题:

Is there a chance that this exact problem (see previous link) is (still) within detectMultiScale ? 是否有这个确切的问题(请参阅上一链接)仍然在detectMultiScale内?

Is there a chance that the problem is not within my project, but in the OpenCV library? 问题是否可能不在我的项目中,而是在OpenCV库中?

Why does this problem only occur in Release mode? 为什么仅在发布模式下会出现此问题?

Why does this problem only occur in the DirectShow filter? 为什么只在DirectShow筛选器中出现此问题? (if I run the "same" code/functionality in Release mode in a stand-alone project, I don't get Debug Assert Failed errors - though there might be a unrecognized memory corruption?!?). (如果在独立项目中以发布模式运行“相同”代码/功能,则不会出现“ Debug Assert Failed错误-尽管可能存在无法识别的内存损坏?!?)。

I hope someone has an idea and thx in advance! 希望有人提前提出想法和建议!

EDIT: 编辑:

ok... I had linked against msvcrtd.lib ... removed the whole lib from my project (seems I didnt even need it) and it "works" now... There is the question left, whether there is some kind of memory leak. 好的...我已经链接到msvcrtd.lib ...从我的项目中删除了整个lib(似乎我什至不需要它),现在它“可以工作了” ...剩下的问题是,是否存在某种内存泄漏。 Or was linking against that lib the only whole problem? 还是与该lib链接是唯一的整体问题?

ok... I had linked against msvcrtd.lib ... 好的...我已经链接到msvcrtd.lib ...

removed the whole lib from my project (so default libs are added?!?) and it "works" now... 从我的项目中删除了整个库(因此添加了默认库?!?),它现在“有效” ...

There is the question left, whether there is some kind of memory leak. 剩下的问题是,是否存在某种内存泄漏。 Or was linking against that lib the only whole problem? 还是与该lib链接是唯一的整体问题?

stupid me... 愚蠢的我...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM