GECKO 1.0
Human-computer interface based on hand gesture recognition
|
Changes the HSV range accordingly with the input skin color image. { //-- Convert from BGR to HSV cv::Mat HSV_ROI; cv::cvtColor( ROI, HSV_ROI, CV_BGR2HSV); //-- Split HSV ROI in channels: std::vector<cv::Mat> HSV_splitted; cv::split( HSV_ROI, HSV_splitted); //-- Calculate values: int hue_mean = median( HSV_splitted[0] ); //int sat_mean = median( HSV_splitted[1] ); //int val_mean = median( HSV_splitted[2] ); int hue_sigma = stdDeviation( HSV_splitted[0] ); //int sat_sigma = stdDeviation( HSV_splitted[1] ); //int val_sigma = stdDeviation( HSV_splitted[2] ); //-- Calculate limits int hue_lower_limit = hue_mean - hue_sigma_mult * hue_sigma / 2; //int sat_lower_limit = sat_mean - sat_sigma_mult * sat_sigma / 2; //int val_lower_limit = val_mean - val_sigma_mult * val_sigma / 2; int hue_upper_limit = hue_mean + hue_sigma_mult * hue_sigma / 2; //int sat_upper_limit = sat_mean + sat_sigma_mult * sat_sigma / 2; //int val_upper_limit = val_mean + val_sigma_mult * val_sigma / 2; //-- Check the limits of the values if ( hue_lower_limit < 0) { int aux = hue_lower_limit; hue_lower_limit = hue_upper_limit; hue_upper_limit = 180 - abs(aux); hue_invert = true; } else if ( hue_upper_limit > 179) { int aux = hue_upper_limit; hue_upper_limit = hue_lower_limit; hue_lower_limit = aux - 180; hue_invert = true; } else hue_invert = false; /* if ( sat_lower_limit < 0) sat_lower_limit = 0; if ( val_lower_limit < 0) val_lower_limit = 0; if ( sat_upper_limit > 255 ) sat_upper_limit = 255; if ( val_lower_limit > 255 ) val_upper_limit = 255; */ //-- Compose the values: // lower_limit = cv::Scalar( hue_lower_limit, sat_lower_limit, val_lower_limit ); // upper_limit = cv::Scalar( hue_upper_limit, sat_upper_limit, val_upper_limit ); lower_limit = cv::Scalar( hue_lower_limit, 58, 89 ); upper_limit = cv::Scalar( hue_upper_limit, 173, 229 ); std::cout << "[Debug] Lower limit is: " << lower_limit << std::endl; std::cout << "[Debug] Upper limit is: " << upper_limit << std::endl; std::cout << "[Debug] Inverting hue: " << hue_invert << std::endl; }
Here is the call graph for this function:
![]() |