基于Boost方法的人脸检测(5):在一张图片中检测人脸
2016-04-30 13:00
447 查看
for (rate = 2; rate <= 7; rate += 1) //for each window
{
len = BaseLen*rate; //检测人脸的窗口边长(默认正方形)[50, 75, 100, 125, 150, 175]
cout << "current window len is: " << len << endl;
step = len/2;
for (x = 0; x < image->width - len; x += step) //for each x
{
for (y = 0; y < image->height - len; y += step) //for each y
{
int faceFlag = 1;
for (j = 0; j < strClfInfoList.size(); j++) //for each str clf
{
strClfInfo = strClfInfoList[j];
result = MyFD(x, y, len, len, sumPixel, strClfInfo, featureList); //(int x, int y, int w, int h)
if (result == 0)//one str clf say this is NOT a face, then REGECT this image
{
//cout << "x=" << x << "; y=" << y << "; len=" << len << " ==> NOT a face" << endl;
faceFlag = 0;
break;
}
}
if (faceFlag == 1) //ALL str clf say this IS a face, then draw
{
//draw window on the img
Point center(x + len*0.5, y + len*0.5);
ellipse(img, center, Size(len*0.5, len*0.5), 0, 0, 360, Scalar(255, 0, 255), 4, 8, 0);
rectangle(img, Point(x, y), Point(x + len, y + len), Scalar(0, 255, 255));
//imshow("FaceDection", img);
//waitKey(0);
}
}
}
}
{
len = BaseLen*rate; //检测人脸的窗口边长(默认正方形)[50, 75, 100, 125, 150, 175]
cout << "current window len is: " << len << endl;
step = len/2;
for (x = 0; x < image->width - len; x += step) //for each x
{
for (y = 0; y < image->height - len; y += step) //for each y
{
int faceFlag = 1;
for (j = 0; j < strClfInfoList.size(); j++) //for each str clf
{
strClfInfo = strClfInfoList[j];
result = MyFD(x, y, len, len, sumPixel, strClfInfo, featureList); //(int x, int y, int w, int h)
if (result == 0)//one str clf say this is NOT a face, then REGECT this image
{
//cout << "x=" << x << "; y=" << y << "; len=" << len << " ==> NOT a face" << endl;
faceFlag = 0;
break;
}
}
if (faceFlag == 1) //ALL str clf say this IS a face, then draw
{
//draw window on the img
Point center(x + len*0.5, y + len*0.5);
ellipse(img, center, Size(len*0.5, len*0.5), 0, 0, 360, Scalar(255, 0, 255), 4, 8, 0);
rectangle(img, Point(x, y), Point(x + len, y + len), Scalar(0, 255, 255));
//imshow("FaceDection", img);
//waitKey(0);
}
}
}
}
相关文章推荐
- 使用JavaScript 实现的人脸检测
- python结合opencv实现人脸检测与跟踪
- JavaScript人脸检测的实现方法
- BioID人脸数据库简介
- [转]浅析人脸检测之Haar分类器方法
- opencv人脸检测基础代码
- 人脸检测的两个参考网址
- 简单的基于YCrCb颜色空间的人脸检测(肤色)
- opencv人脸检测
- 利用Adaboost和LBP特征进行人脸检测
- 人脸特征点检测
- 鲁棒的实时人脸检测:Robust Real-Time Face Detection
- 浅析人脸检测之Haar分类器方法(一)
- 基于Boost方法的人脸检测(1):整体思路
- 基于Boost方法的人脸检测(2):样本生成(切割图像、resize图像、灰度化图像、保存图片)
- 基于Boost方法的人脸检测(3):特征生成、特征值计算(积分图)
- opencv 实现人脸检测(opencv3.3 + visual studio 2017)
- OpenCV+Dlib实现人脸68个特征点检测
- OpenCV+Dlib进行实时脸部检测
- 如何快糙好猛的使用libfacedetection库【最新版】