标签:级联 haar 分类器 均衡化 tor cascade make 直方图均衡化 col
1 #include <opencv2/opencv.hpp> 2 #include <iostream> 3 4 using namespace cv; 5 using namespace std; 6 7 int main(int argc, char** argv) { 8 String cascadeFilePath = "F:/CMake_bulid/install/etc/haarcascades/haarcascade_frontalface_alt.xml";//数据路径 9 CascadeClassifier face_cascade;//创建分类器对象 10 if (!face_cascade.load(cascadeFilePath)) { 11 printf("could not load haar data...\n"); 12 return -1; 13 } 14 15 VideoCapture Capture(0); 16 Mat src, gray_src; 17 while(Capture.read(src)){ 18 19 cvtColor(src, gray_src, COLOR_BGR2GRAY); 20 equalizeHist(gray_src, gray_src);//直方图均衡化 21 22 vector<Rect> faces; 23 face_cascade.detectMultiScale(gray_src, faces, 1.1, 2, 0, Size(30, 30));//多尺度查找 24 for (size_t t = 0; t < faces.size(); t++) { 25 rectangle(src, faces[t], Scalar(0, 0, 255), 2, 8, 0); 26 } 27 namedWindow("output", CV_WINDOW_AUTOSIZE); 28 imshow("output", src); 29 30 uchar key = waitKey(100); 31 if(key==27) 32 { 33 break; 34 } 35 36 } 37 waitKey(0); 38 return 0; 39 }
标签:级联 haar 分类器 均衡化 tor cascade make 直方图均衡化 col
原文地址:https://www.cnblogs.com/long5683/p/9740250.html