根据人脸分类器检测人脸
一、代码
#include <iostream>
#include <opencv2/opencv.hpp>
#define N_BINS 16
#define N_DIVS 3
#define N_PHOG N_DIVS*N_DIVS*N_BINS
#define BIN_RANGE (2*CV_PI)/N_BINS
using namespace std;
using namespace cv;
const string SF="D:\\code\\c\\opencv\\opencv_face_catch\\sample";
const string OF="D:\\code\\c\\opencv\\opencv_face_catch\\output";
const string TF="D:\\code\\c\\opencv\\opencv_face_catch\\sample\\main.txt";
const string CF="E:\\Application\\opencv\\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\\etc\\haarcascades\\haarcascade_frontalface_alt.xml";
char char_filename[1024];
Mat hog(const Mat &Img);
string change_int_to_char(int a);
void change_string_to_char(string s);
int main()
{
CascadeClassifier faceCascader;
string filename;
VideoCapture capture;
Mat img,feature,img_gray,new_img,show_img,gray;
int f1,f2,svm_t=0;
cv::Ptr<cv::ml::SVM> svm[10];
char file[20],fname[10][20];
int id,SFN,mid;
Rect roi;
vector<Rect> face;
FILE *fp;
change_string_to_char(TF);
fp=fopen(char_filename,"rb");
while(fscanf(fp,"%d %s %d",&id,file,&SFN)!=EOF)
{
if(id==0)
continue;
filename=OF+"\\"+file+"_"+change_int_to_char(id)+".xml";
svm[id-1]=cv::ml::StatModel::load<cv::ml::SVM>(filename);
if(svm[id