一、人脸识别代码
#include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"#include "opencv2/imgproc.hpp"
#include <iostream>
#include "stdafx.h"
using namespace std;
using namespace cv;
//人脸识别的步骤
//1、打开摄像头
//2、加载摄像头参数
//3、加载分类器
//4、识别
//5、画图
//6、显示
class face_detect
{
public:
face_detect();
~face_detect();
int open_carmera();
int load_carmera_data();
int load_classifier_data(CascadeClassifier& type_classifier, string path);
int show_carmera();
int face_recognition(CascadeClassifier& type_classifier, vector<Rect>& type);
int drawing(vector<Rect>& type);
private:
VideoCapture cap;
Mat frame;
CascadeClassifier face_classifier;
vector<Rect> face, face2;
};
face_detect::face_detect()
{
}
face_detect::~face_detect()
{
}
//1、打开摄像头
int face_detect::open_carmera()
{
cap.open(0);