//#include "stdafx.h"
#include <opencv2\opencv.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <math.h>
using namespace cv;
using namespace std;
//读取image存入Mat中
static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ',') {
std::ifstream file(filename.c_str(), ifstream::in);
if (!file) {
string error_message = "No valid input file was given, please check the given filename.";
CV_Error(CV_StsBadArg, error_message);
}
string line, path, classlabel;
while (getline(file, line)) {
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()));
}
}
}
void main()
{
CascadeClassifier cas("haarcascade_frontalface_default.xml"); //加载人脸分类器
char str[20];
//at.txt存放在项目目录下
string fn_csv = &