#include <opencv2/opencv.hpp>
#include <iostream> using namespace cv;
using namespace std; int main(int argc, char** argv) {
String cascadeFilePath = "F:/CMake_bulid/install/etc/haarcascades/haarcascade_frontalface_alt.xml";//数据路径
CascadeClassifier face_cascade;//创建分类器对象
if (!face_cascade.load(cascadeFilePath)) {
printf("could not load haar data...\n");
return -;
} VideoCapture Capture();
Mat src, gray_src;
while(Capture.read(src)){ cvtColor(src, gray_src, COLOR_BGR2GRAY);
equalizeHist(gray_src, gray_src);//直方图均衡化 vector<Rect> faces;
face_cascade.detectMultiScale(gray_src, faces, 1.1, , , Size(, ));//多尺度查找
for (size_t t = ; t < faces.size(); t++) {
rectangle(src, faces[t], Scalar(, , ), , , );
}
namedWindow("output", CV_WINDOW_AUTOSIZE);
imshow("output", src); uchar key = waitKey();
if(key==)
{
break;
} }
waitKey();
return ;
}
04-16 07:56