| 
    GECKO 1.0 
   Human-computer interface based on hand gesture recognition 
   | 
 
 Removes the face from the src image. -- {
    //-- Create variables to store faces
    std::vector< cv::Rect > detectedFaces;
    //-- Convert the source image to a greyscale image:
    cv::Mat srcGrey;
    cv::cvtColor( src, srcGrey, CV_BGR2GRAY );
    cv::Mat srcGreySmall;
    cv::resize( srcGrey, srcGreySmall, cv::Size(0, 0), 0.25, 0.25 );
    //-- Detect face:
    faceDetector.detectMultiScale( srcGreySmall, detectedFaces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, cv::Size( 30, 30) );
    dstMask = cv::Mat(  srcGrey.size() , CV_8UC1,  cv::Scalar( 255, 255, 255) );
    //-- Clear detected faces:
    lastFacesPos.clear();
    //-- Show detected faces:
    if ( ! detectedFaces.empty() )
    {
        for (int i = 0; i < detectedFaces.size(); i++)
        {
            cv::Rect resizedRect;
            if ( factorX == 1 && factorY == 1 )
            {
                //-- Do not resize:
                resizedRect = cv::Rect( detectedFaces[i].x * 4,
                                        detectedFaces[i].y * 4,
                                        detectedFaces[i].width  * 4,
                                        detectedFaces[i].height * 4 );
            }
            else
            {
                //-- Resize:
                //-- Calculate original center:
                double cx = detectedFaces[i].x * 4 + detectedFaces[i].width * 2;
                double cy = detectedFaces[i].y * 4 + detectedFaces[i].height * 2;
                //-- Calculate new size:
                double newW = detectedFaces[i].width * 4 * factorX;
                double newH = detectedFaces[i].width * 4 * factorY;
                //-- Calculate new center:
                double newX = cx - newW / 2;
                double newY = cy - newH / 2;
                resizedRect = cv::Rect( newX, newY, newW, newH );
            }
            cv::rectangle( dstMask, resizedRect, cv::Scalar( 0, 0, 0), CV_FILLED );
            //-- Save rectancle
            lastFacesPos.push_back( resizedRect );
        }
    }
}
 | 
  
 1.7.4