l恒星l 2018-12-25 13:23 采纳率: 0%
浏览 3544

OpenCV3.4.1+VS2017人脸识别Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create ()无法解析

#include<iostream> 
#include <opencv2\opencv.hpp> 
#include <fstream> 
#include <sstream> 
#include <opencv2\face\facerec.hpp> 
#include <windows.h>  
#include  <direct.h>
using namespace cv;
using namespace std;
using namespace face;

CascadeClassifier face_cascades;

void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';')
{
    std::ifstream file(filename, ifstream::in);//c_str()函数可用可不用,无需返回一个标准C类型的字符串
    if (!file) 
    {

        string error_message = "No valid input file was given, please check the given filename.";

        CV_Error(CV_StsBadArg, error_message);

    }
    else
    {
        cout << "first ok !" << endl;
    }

    string line, path, classlabel;
int i = 1;
    while (getline(file, line))//从文本文件中读取一行字符,未指定限定符默认限定符为“/n”

    {

        stringstream liness(line);//这里采用stringstream主要作用是做字符串的分割

        getline(liness, path, separator);//读入图片文件路径以分好作为限定符

        getline(liness, classlabel);//读入图片标签,默认限定符

        if (!path.empty() && !classlabel.empty())//如果读取成功,则将图片和对应标签压入对应容器中 

        {


            cout << "second ok!" << i << endl;
            images.push_back(imread(path, 0));

            labels.push_back(atoi(classlabel.c_str()));
            i++;
        }

    }
}

int main()
{
    String csvPath = "E:\\ORL\\at.txt";
    vector<Mat> images;
    vector<int> labels;
    read_csv(csvPath, images, labels);
    //imshow("as", images);
    imshow("fsed", labels);
    cout << labels.size() << endl;
    Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create ();
    //Ptr < BasicFaceRecognizer > model = EigenFaceRecognizer::create();
    model->train(images, labels);
    model->save("E:\\ORL\\PCA_Model.xml");
    waitKey(0);
    system("pause");
    return 0;
}

运行后两个错误
第一个错误 LNK1120 1 个无法解析的外部命令 Project3 E:\OpenCV project\Project3\x64\Debug\Project3.exe 1

严重性 代码 说明 项目 文件 行 禁止显示状态
第二错误 LNK2019 无法解析的外部符号 "public: static struct cv::Ptr __cdecl cv::face::EigenFaceRecognizer::create(int,double)" (?create@EigenFaceRecognizer@face@cv@@SA?AU?$Ptr@VEigenFaceRecognizer@face@cv@@@3@HN@Z),该符号在函数 main 中被引用 Project3 E:\OpenCV project\Project3\Project3\源.obj 1

  • 写回答

2条回答 默认 最新

  • 噗嗤bilibala 2021-02-04 12:30
    关注

    怎么解决啊?

     

    评论

报告相同问题?

悬赏问题

  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题