找回密码
 立即注册
收起左侧

Opencv 人脸识别在Qt中出现错误

0
回复
9078
查看
[复制链接]
累计签到:3 天
连续签到:1 天
来源: 2017-4-16 15:31:07 显示全部楼层 |阅读模式
1Qter豆
本帖最后由 Lynncn 于 2017-4-16 15:34 编辑

#include <QCoreApplication>#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/face/predict_collector.hpp>#include <opencv2/face/facerec.hpp>#include "opencv2/core.hpp"#include "opencv2/face.hpp"#include "opencv2/highgui.hpp"#include "opencv2/imgproc.hpp"#include <iostream>#include <fstream>#include <sstream>#include <vector>#include <string>
using namespace cv;using namespace std;using namespace cv::face;
int main(){        // 训练模型  
  vector<Mat> images;   
vector<int> labels;   
std::string fn_csv = "/home/xiaofu/workfiles/image_cvs.txt";   
std::string saveModelPath = "/home/xiaofu/workfiles/trainModel.xml";   
std::string filename = fn_csv;   
string error_message;    //read txt    char separator = ';';   
std::ifstream file(filename.c_str(), ifstream::in);   
if (!file) {      
error_message = "No valid input file was given, please check the given filename.";   
}   
string line, path, classlabel;  
  while (getline(file, line)) {     
   if (line.c_str()[0 == '#') {      
     continue;        }      
  stringstream liness(line);     
   getline(liness, path, separator);      
  getline(liness, classlabel);     
   if (!path.empty() && !classlabel.empty()) {     
       images.push_back(imread(path, 0));      
      labels.push_back(atoi(classlabel.c_str()));        }    }
    if (images.size() <= 1) {      
  error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
    }  
  Ptr<BasicFaceRecognizer> model = createEigenFaceRecognizer();   
    model->train(images, labels);        
model->save(saveModelPath);      
  return 0;
}
错误提示:/usr/local/include/opencv2/face/predict_collector.hpp:76: error: expected unqualified-id before 'const'     CV_WRAP virtual bool emit(const int label, const double dist, const int state = 0); //not abstract while Python generation require non-abstract class                               ^/usr/local/include/opencv2/face/predict_collector.hpp:76: error: expected ')' before 'const'
/usr/local/include/opencv2/face/predict_collector.hpp:91: error: expected unqualified-id before 'const'     CV_WRAP bool emit(const int label, const double dist, const int state = 0);                       ^/usr/local/include/opencv2/face/predict_collector.hpp:91: error: expected ')' before 'const'
predict_collector.hpp没有修改过,不知道问题出在哪里,求大神解答,在线等。。


附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了