cvHaarDetectObjects如何工作?

时间:2012-09-13 11:04:10

标签: c++ opencv face-detection

我正在尝试学习cvHaarDetectObjects的工作原理...... 我无法想象它是如何工作的......如何计算积分图像并找到一张脸......

我们在脸部区域放了一个矩形......我们如何找到这个区域?

if (faces)
{
    for(int i = 0; i < faces->total; ++i)
    {
        CvPoint point1, point2;
        CvRect* rectangle = (CvRect*)cvGetSeqElem(faces, i);
        point1.x = rectangle->x;
        point2.x = (rectangle->x + rectangle->width);
        point1.y = rectangle->y;
        point2.y = (rectangle->y + rectangle->height);
        cvRectangle(frame, point1, point2, CV_RGB(255,0,0));...

2 个答案:

答案 0 :(得分:2)

阅读此维基页面, http://en.wikipedia.org/wiki/Viola%E2%80%93Jones_object_detection_framework

有一种名为Viola Jones的着名算法: http://research.microsoft.com/en-us/um/people/viola/Pubs/Detect/violaJones_CVPR2001.pdf

希望它能帮助您了解其工作原理。

答案 1 :(得分:0)

在OpenCV库中通过两个角(SO

)组成一个矩形
point1.x = rectangle->x;
point2.x = (rectangle->x + rectangle->width);
point1.y = rectangle->y;
point2.y = (rectangle->y + rectangle->height);

来自

CvRect* rectangle = (CvRect*)cvGetSeqElem(faces, i);

获取检测面部的位置,它使用那些x和y坐标,用它们组成两个所需的品脱(上面的代码),然后用点作为参数绘制矩形:

cvRectangle(frame, point1, point2, CV_RGB(255,0,0));