|
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没有修改过,不知道问题出在哪里,求大神解答,在线等。。
|
|