OpenCV 2.1:faceDetect.cpp 在发现丑陋的面孔时崩溃

发布于 2024-12-07 00:17:10 字数 815 浏览 0 评论 0原文

我正在尝试编译 facedetect.cpp 在 Visual Studio 2010 中的 OpenCV\Samples\C 文件夹中。该项目编译并开始得很好,显示了我的相机的预览,然后似乎在 Cascade.DetectMultiScale() 处崩溃了检测到一张脸。我的结论是OpenCV认为我太丑了。

HeadTrackerExample.exe 中 0x100342bf 处未处理的异常:0xC0000005:写入位置 0x00000000 时发生访问冲突。

不幸的是,调试信息不​​允许我更深入地探究。我正在链接 cv210.lib;cxcore210.lib;highgui210.lib;调试版本不起作用:

LDR: LdrpWalkImportDescriptor() 无法探测 D:\OpenCV2.1\bin\cv210d.dll 的清单,ntstatus 0xc0150002

我将尝试欺骗带有安妮海瑟薇打印输出的分类器,但我愿意接受其他建议。

https://code.ros.org/trac /opencv/browser/trunk/opencv/samples/c/facedetect.cpp

I am trying to compile the facedetect.cpp in the OpenCV\Samples\C folder, in Visual Studio 2010. The project compiles and begins just fine, shows a preview of my camera, and then seems to crash at cascade.detectMultiScale() as soon as it detects a face. I concluded that OpenCV thinks I am too ugly.

Unhandled exception at 0x100342bf in HeadTrackerExample.exe: 0xC0000005: Access violation writing location 0x00000000.

Unfortunately the debug info doesn't let me probe deeper. I am linking against cv210.lib;cxcore210.lib;highgui210.lib; the debug versions won't work:

LDR: LdrpWalkImportDescriptor() failed to probe D:\OpenCV2.1\bin\cv210d.dll for its manifest, ntstatus 0xc0150002

I'm going to try to trick the classifier with a printout of Anne Hathaway but I am open to other suggestions.

https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/c/facedetect.cpp

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何以畏孤独 2024-12-14 00:17:10

我想我比你好看,因为它在这里工作(在 OS X 下)。您确定已成功加载 xml 文件吗?您是否使用默认的 xml 文件(haarcascade_frontalface_alt.xml 和 haarcascade_eye_tree_eyeglasses.xml)?

看起来你确实有一个空指针。尝试在调用 cascade.detectMultiScale() 时设置断点,并检查 cascadesmallImgsmallImg.data< 的值/code> 和面孔

编辑:填充faces向量

这是detectMultiScale代码:

void HaarClassifierCascade::detectMultiScale( const Mat& image,
                       Vector<Rect>& objects, double scaleFactor,
                       int minNeighbors, int flags,
                       Size minSize )
{
    MemStorage storage(cvCreateMemStorage(0));
    CvMat _image = image;
    CvSeq* _objects = cvHaarDetectObjects( &_image, cascade, storage, scaleFactor,
                                           minNeighbors, flags, minSize );
    Seq<Rect>(_objects).copyTo(objects);
}

直到最后一行才接触faces向量全部检测完成。如果您喜欢冒险,可以在此处抛出一些 printf 语句来查看 cvHaarDetectObjects 是否正在完成以及是否返回空指针。

I guess I'm better looking than you because it's working here (under OS X). Are you sure you're successfully loading the xml files? Are you using the default xml files (haarcascade_frontalface_alt.xml and haarcascade_eye_tree_eyeglasses.xml)?

It sure looks like you have a null pointer. Try setting a breakpoint at the call to cascade.detectMultiScale() and examine the values of cascade, smallImg, smallImg.data, and faces.

Edit: populating the faces vector

Here's the detectMultiScale code:

void HaarClassifierCascade::detectMultiScale( const Mat& image,
                       Vector<Rect>& objects, double scaleFactor,
                       int minNeighbors, int flags,
                       Size minSize )
{
    MemStorage storage(cvCreateMemStorage(0));
    CvMat _image = image;
    CvSeq* _objects = cvHaarDetectObjects( &_image, cascade, storage, scaleFactor,
                                           minNeighbors, flags, minSize );
    Seq<Rect>(_objects).copyTo(objects);
}

It's not touching the faces vector until the last line after all the detection is done. If you are adventurous, you could throw some printf statements in here to see if cvHaarDetectObjects is completing and if it is returning a null pointer.

韶华倾负 2024-12-14 00:17:10

我花了一天时间试图解决这个问题。谁知道为什么会崩溃?我无法链接到调试 DLL,所以我们永远不会知道。我下载了 OpenCV-2.1.0-win32-vs2008.exe 发行版。我使用的是 Visual Studio 2010。因此,exe 因 LDR 崩溃

:LdrpWalkImportDescriptor() 无法探测 D:\OpenCV2.1\bin\cv210d.dll 的清单,ntstatus 0xc0150002
调试器:: 在进程加载期间抛出未处理的不可继续异常
程序“[5172] HeadTrackerExample.exe: Native”已退出,代码为 -1072365566 (0xc0150002)。

这是“0xc0150002 错误”。根据 Dependency Walker 的说法,OpenCV 调试 DLL 正在尝试查找 msvcr90d.dll 和 msvct90d.dll(Visual Studio 2008 调试运行时 DLL)。好吧,我获得了这些,但它仍然不起作用,所以接下来就涉及到深奥的 Windows 并排和清单内容了。

我切换到 OpenCV-2.3.1-win-superpack.exe 发行版,它现在可以工作了。

I spent the day trying to fix this. Who knows why it was crashing? I couldn't link to the debug DLLs so we'll never know. I downloaded the OpenCV-2.1.0-win32-vs2008.exe distribution. And I am using Visual Studio 2010. Therefore, the exe was crashing with

LDR: LdrpWalkImportDescriptor() failed to probe D:\OpenCV2.1\bin\cv210d.dll for its manifest, ntstatus 0xc0150002
Debugger:: An unhandled non-continuable exception was thrown during process load
The program '[5172] HeadTrackerExample.exe: Native' has exited with code -1072365566 (0xc0150002).

This is the "0xc0150002 error". According to Dependency Walker, the OpenCV debug DLLs are trying to find msvcr90d.dll and msvct90d.dll, the Visual Studio 2008 debug runtime DLLs. Well, I obtained these and it still didn't work, so then this gets into esoteric Windows sidebyside and manifest stuff.

I switched to the OpenCV-2.3.1-win-superpack.exe distribution and it is now working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文