GECKO 1.0
Human-computer interface based on hand gesture recognition
void HandDescriptor::defectsExtraction ( ) [private]

Finds the convexity defects of the hand convex hull, that are used to find the fingers.

{
    std::vector< cv::Vec4i > convexity_defects;

    //-- Find the complex hull
    cv::convexHull( _hand_contour[0], _hand_hull, CV_CLOCKWISE);

    //-- Find convexity defects:
    std::vector<int> hull_indices;
    cv::convexHull( _hand_contour[0], hull_indices, CV_CLOCKWISE);

    try
    {
        cv::convexityDefects( _hand_contour[0], hull_indices, convexity_defects );
    }
    catch ( std::exception& e)
    {
        std::cerr << e.what() ;
        _hand_found = false;
        return;
    }


    //-- Convert the found defects to a more convenient format:
    _hand_convexity_defects.clear();
    //std::cout << "[Debug] Found " << convexity_defects.size() << " defects:" << std::endl;
    for (int i = 0; i < convexity_defects.size(); i++)
    {
        ConvexityDefect newDefect;

        newDefect.start_index = convexity_defects[i][0];
        newDefect.start = _hand_contour[0].at( newDefect.start_index );

        newDefect.end_index = convexity_defects[i][1];
        newDefect.end = _hand_contour[0].at( newDefect.end_index );

        newDefect.depth_point_index = convexity_defects[i][2];
        newDefect.depth_point = _hand_contour[0].at( newDefect.depth_point_index );

        newDefect.depth = convexity_defects[i][3] / 256.0;

        _hand_convexity_defects.push_back( newDefect );

        //std::cout << "\t" << i << "-> (" << newDefect.start_index << ", " << newDefect.end_index << ", " << newDefect.depth_point_index << ")" << std::endl;
    }


}
 All Classes Functions Variables