如何在openCV 2.3.1中加载xml级联文件

发布于 2024-12-27 17:52:07 字数 526 浏览 1 评论 0原文

我尝试使用 C++ 和 OpenCV 2.3.1 库在 Visual Studio 2010 上构建人脸检测应用程序 因此,我声明 String 类型并初始化:

字符串face_cascade_name =“haarcascade_frontalface_alt.xml”;

接下来,我创建 CascadeClassifier 类的对象:

级联分类器face_cascade;

我加载级联:

if( !face_cascade.load(face_cascade_name) ){ printf("--(!)加载错误\n");返回-1; };

项目构建和调试没有问题,但是当我运行应用程序和应用程序尝试加载级联程序崩溃!

我看到了这样的通讯: 程序“[1288] OpenCV2.0.exe:Native”已退出,代码为-1 (0xffffffff)。

I try bulid face detect applicatyion on Visual Studio 2010 using C++ and OpenCV 2.3.1 library
So, I declaration String type and initialize:

String face_cascade_name = "haarcascade_frontalface_alt.xml";

Next, I create a object of class CascadeClassifier:

CascadeClassifier face_cascade;

And I load cascade:

if( !face_cascade.load(face_cascade_name) ){ printf("--(!)Error loading\n"); return -1; };

The project bulid and debugging without problem, but when I run application and application try load cascade program crash!

And I see this communication:
The program '[1288] OpenCV2.0.exe: Native' has exited with code -1 (0xffffffff).

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

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

发布评论

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

评论(3

灵芸 2025-01-03 17:52:07

我对 CascadeClassifier 和 FileStorage 也有同样的问题。

例如,如果您尝试这样做:

FileStorage fs(xml_fname, FileStorage::READ);
if (!fs.isOpened())
{
    cout<<"can not read xml"<<endl;
}

可能不会起作用。

就我而言,我将 VC++ 从调试模式传递到发布模式,指定最后没有 d.lib 文件(例如 opencv_core231.lib )现在可以使用了。

I had the same problem with CascadeClassifier and FileStorage.

For example if you try this:

FileStorage fs(xml_fname, FileStorage::READ);
if (!fs.isOpened())
{
    cout<<"can not read xml"<<endl;
}

Probably, it won't work.

In my case, I passed in VC++ from Debugging mode to Release mode, specified .lib files without d at the end (e.g. opencv_core231.lib) and it works now.

遗失的美好 2025-01-03 17:52:07

就我而言(OSX 10.9),我输入整个路径而不是简单的“haarcascade_frontalface_alt.xml”,例如“/Users/xxx/Desktop/opencv-2.4.7/data/haarcascades/haarcascade_frontalface_alt.xml”。祝你好运

In my case(OSX 10.9), I input the whole path instead of simply "haarcascade_frontalface_alt.xml", like "/Users/xxx/Desktop/opencv-2.4.7/data/haarcascades/haarcascade_frontalface_alt.xml". Good Luck

樱&纷飞 2025-01-03 17:52:07

就我而言(win7 64,VS 10 express),更改 xml 文件的文件权限解决了问题,
我添加了具有完全控制权的每个人,并且它起作用了。

In my case (win7 64, VS 10 express), changing file permissions for xml files solved the problem,
I added Everyone with full controll, and it worked.

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