使用Cascade.load()在Opencv中加载级联分类器时出错! [英] Error in loading cascade classifier in Opencv using cascade.load()!

查看:707
本文介绍了使用Cascade.load()在Opencv中加载级联分类器时出错!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用opencv示例中提供的facedetect.cpp代码. 但是在构建和运行之后出现错误是因为cascade.load(cascadeName)给定错误,即返回零. 几天前它在工作.突然,这个错误开始出现. 我也是XML文件的完整路径,但是没有用! 此命令用于运行代码的可执行文件:

I am using the facedetect.cpp code given in opencv samples. But the after building and running an error comes up because cascade.load(cascadeName) given an error i.e. returns zero. It was working a few days ago. Suddenly this error started to come. I also the full path of the XML file,but it did not work! This command was used to run the executable of the code :

`objectDetect --cascade="Full path to haarcascade_frontalface_alt.xml" --scale=1.3 %1`

XML文件的路径正确!! 请检查此快照

The path of the XML file is correct!! Kindly check this snap shot

#include <opencv2\objdetect\objdetect.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <cv.h>
#include <highgui.h>
#include <iostream>

using namespace std;
using namespace cv;

int main(int argc, char* argv[]) {
string xmlArray[] = {
"D:/Visual Studio 2010/Projects/loadClassifierTest/haarcascades/haarcascade_eye.xml",
"D:/Visual Studio 2010/Projects/loadClassifierTest/haarcascades/haarcascade_eye_tree_eyeglasses.xml",
"D:/Visual Studio 2010/Projects/loadClassifierTest/haarcascades/haarcascade_frontalface_alt.xml",
"D:/Visual Studio 2010/Projects/loadClassifierTest/haarcascades/haarcascade_frontalface_alt2.xml",
"D:/Visual Studio 2010/Projects/loadClassifierTest/haarcascades/haarcascade_frontalface_alt_tree.xml",
"D:/Visual Studio 2010/Projects/loadClassifierTest/haarcascades/haarcascade_frontalface_default.xml",
"D:/Visual Studio 2010/Projects/loadClassifierTest/haarcascades/haarcascade_fullbody.xml"
};
CascadeClassifier cascade;
for (int i = 0; i < 6; ++i) {
    if (!cascade.load(xmlArray[i]))
        cerr << "Could not load " << xmlArray[i] << " !" << endl;
    else
        cout << xmlArray[i] << " has been loaded!" << endl;
}
return 0;
}

所有xml文件都位于同一文件夹中.即使提供了完整路径,它们也没有加载.我认为没有任何许可问题...

All the xml files are in the same folder .... even after giving the full path .... they are not loading ... ! I don't think that there are any permission issues ...

请帮助!

推荐答案

您是否尝试过以这种方式传递绝对路径:

Have you tried passing absolute path in this way:

 String xmlFilePath = "c:/.../haarcascade_frontalface_alt.xml";

您的文件是否位于具有读取权限的文件夹中?

Is your file in a folder with Read-permission?

它应该可以工作,否则问题出在代码的另一个地方.

It should work, otherwise the problem is in another place of your code..

这篇关于使用Cascade.load()在Opencv中加载级联分类器时出错!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆