EigenFaceRecognizer::create()无法解析的外部符号

#include <opencv2/opencv.hpp>
#include <iostream>
#include <opencv2/face.hpp>

using namespace std;
using namespace cv;
using namespace cv::face;
char wintitle[40] = {};
int main(int argc, char** argv) {
	string filename = string("D:/Project/image/data_faces/1.csv");
	ifstream file(filename.c_str(), ifstream::in);
	if (!file) {
		printf("colud not load file correctly...\n");
		return -1;
	}
	string line, path, classlabel;
	vector<Mat> images;
	vector<int> labels;
	char separator = ';';
	while (getline(file, line))
	{
		stringstream liness(line);
		getline(liness, path, separator);
		getline(liness, classlabel);
		if (!path.empty() && !classlabel.empty()) {
			printf("path: %s\n", path.c_str());
			images.push_back(imread(path ,0));
			labels.push_back(atoi(classlabel.c_str()));
		}
	}
	if (images.size() < 1 || labels.size() < 1) {
		printf("invalid image path...\n");
		return -1;
	}
	int height = images[0].rows;
	int width = images[0].cols;
	printf("height:%d,width:%d\n", height, width);
	Mat testSample = images[images.size() - 1];
	int testLabel = labels[labels.size() - 1];
	images.pop_back();
	labels.pop_back();
	
	
	Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();
	model->train(images, labels);

	int predictedLabel = model->predict(testSample);
	printf("actual label:%d,predict label:%d\n", testLabel, predictedLabel);
	Mat eigenvalues = model->getEigenValues();
	Mat eigenvector = model->getEigenVectors();
	Mat mean = model->getMean();
	Mat meanFace = mean.reshape(1, height);
	Mat dst;
	if (meanFace.channels() == 1) {
		normalize(meanFace, dst, 0, 255, NORM_MINMAX, CV_8UC1);
	}
	else if (meanFace.channels() == 3) {
		normalize(meanFace, dst, 0, 255, NORM_MINMAX, CV_8UC3);
	}
	imshow("Mean Face", dst);
	
	for (int i = 0; i < min(10, eigenvalues.cols); i++) {
		Mat ev = eigenvalues.col(i).clone();
		Mat grayscale;
		Mat eigenFace = ev.reshape(1, height);
		if (eigenFace.channels() == 1) {
			normalize(eigenFace, grayscale, 0, 255, NORM_MINMAX, CV_8UC1);
		}
		else if (eigenFace.channels() == 3) {
			normalize(eigenFace, grayscale, 0, 255, NORM_MINMAX, CV_8UC3);
		}
		Mat colorface;
		applyColorMap(grayscale, colorface, COLORMAP_BONE);
		sprintf_s(wintitle, "eigenface_%d", i);
		imshow(wintitle, colorface);
	}
	waitKey(0);
	return 0;
}

OpenCV人脸识别中出现EigenFaceRecognizer::create()无法解析,请问大神们怎么解决?编译环境VS2019社区版+Opencv3413

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值