GECKO 1.0
Human-computer interface based on hand gesture recognition
|
Extract the hand contours from a binary image containing hand candidates. After the contour extraction it filters out the smaller contours, that are likely to be noise, and carries a polygon approximation to reduce the number of points in the contour.
{ const int epsilon = 1; //-- Max error for polygon approximation //-- Extract skin contours: std::vector<std::vector<cv::Point> > raw_contours; cv::findContours(skinMask, raw_contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cv::Point(0,0) ); //-- Filter the contours by size: std::vector<std::vector<cv::Point> > filtered_hand_contours; filterContours( raw_contours, filtered_hand_contours); //-- Set a flag in case no hands have been found: _hand_found = (int) filtered_hand_contours.size() > 0 ; //-- If contour was found, make a aproximation of them: _hand_contour = std::vector<std::vector<cv::Point > >( filtered_hand_contours.size() ); if ( _hand_found ) for( int i = 0; i < filtered_hand_contours.size(); i++) cv::approxPolyDP( filtered_hand_contours[i], _hand_contour[i], epsilon, True ); } |