如何在openCV 2.3.1中加载xml级联文件
我尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我对 CascadeClassifier 和 FileStorage 也有同样的问题。
例如,如果您尝试这样做:
可能不会起作用。
就我而言,我将 VC++ 从调试模式传递到发布模式,指定最后没有
d
的.lib
文件(例如opencv_core231.lib
)现在可以使用了。I had the same problem with
CascadeClassifier
andFileStorage
.For example if you try this:
Probably, it won't work.
In my case, I passed in VC++ from Debugging mode to Release mode, specified
.lib
files withoutd
at the end (e.g.opencv_core231.lib
) and it works now.就我而言(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
就我而言(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.