使用级联分类器实现人脸检测(OpenCV自带的数据)

 #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 ;
}
上一篇:神舟zx6-ct5da装黑苹果Macos 10.15.6记录


下一篇:No cached version of cn.lightsky.infiniteindicator:library:1.2.2 available for offline mode.