|
GECKO 1.0
Human-computer interface based on hand gesture recognition
|
Extracts a mask of the region of interest in which the hand is contained.
{
//-- Pointers for writting less (and better reading)
int * x = &(_max_circle_incribed_center.x);
int * y = &(_max_circle_incribed_center.y);
double * r = &(_max_circle_inscribed_radius);
std::cout << "[Debug] ROI circle: Center at (" << *x << ", " << *y << ") R = " << *r << std::endl;
//-- Extract hand ROI:
int ROI_corner_x = (*x) - 3.5*(*r);
int ROI_corner_y = (*y) - 3.5*(*r);
int ROI_width, ROI_height;
ROI_width = ROI_height = 7*(*r);
//-- Check for limits:
if (ROI_corner_x + ROI_width > src.cols)
ROI_width = src.cols - ROI_corner_x;
if (ROI_corner_y + ROI_height > src.rows)
ROI_height = src.rows - ROI_corner_y;
cv::Rect ROI_rectangle = cv::Rect( ROI_corner_x, ROI_corner_y, ROI_width, ROI_height );
try
{
//_hand_ROI = src( ROI_rectangle ).clone();
_hand_ROI = cv::Mat::zeros( src.size(), CV_8UC1);
cv::rectangle( _hand_ROI, ROI_rectangle, cv::Scalar( 255, 255, 255), CV_FILLED);
}
catch( std::exception& e)
{
std::cerr << "An exception ocurred, but we are crossing fingers and ignoring it... :)" << std::endl;
}
//cv::imshow("[Debug] Hand", _hand_ROI);
}
|
1.7.4