|
GECKO 1.0
Human-computer interface based on hand gesture recognition
|
Extracts the hand center and applies a Kalman Filter for improved stability. {
//-- Predict next center position with kalman filter:
cv::Mat prediction = kalmanFilterCenter.predict();
_hand_center_prediction = cv::Point( prediction.at<float>(0), prediction.at<float>(1) );
//-- Measure actual point (uncomment the selected method):
//-------------------- With RotatedRect --------------------------------------
// cv::Point2f rect_points[4]; _hand_rotated_bounding_box.points( rect_points );
// for( int j = 0; j < 4; j++ )
// {
// cog.first += rect_points[j].x;
// cog.second += rect_points[j].y;
// }
// cog.first /= 4;
// cog.second /= 4;
//-------------------- With Bounding Rectangle --------------------------------
//-- (This is more stable than the rotated rectangle)
// _hand_center.first = _hand_bounding_box.x + _hand_bounding_box.width / 2;
// _hand_center.second = _hand_bounding_box.y + _hand_bounding_box.height / 2;
//-------------------- Using Max. Inscribed Circle -----------------------------
_hand_center = _max_circle_incribed_center;
//-- Create matrix for storing the measurement (measured position of hand)
cv::Mat_<float> measurement(2, 1);
measurement(0) = _hand_center.x;
measurement(1) = _hand_center.y;
//-- Correct estimation:
cv::Mat estimation = kalmanFilterCenter.correct( measurement);
_hand_center_estimation = cv::Point( estimation.at<float>(0), estimation.at<float>(1) );
}
|
1.7.4