Skip to content

Instantly share code, notes, and snippets.

@UnaNancyOwen
Last active July 14, 2016 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UnaNancyOwen/51c55a91e6750230112b4f1649f108d5 to your computer and use it in GitHub Desktop.
Save UnaNancyOwen/51c55a91e6750230112b4f1649f108d5 to your computer and use it in GitHub Desktop.
inline void result( const CComPtr<IVisualGestureBuilderFrame>& gestureFrame, const CComPtr<IGesture>& gesture, const int count )
{
// TrackingIdを取得
UINT64 trackingId;
ERROR_CHECK( gestureFrame->get_TrackingId( &trackingId ) );
// Gestureの種類(Discrete or Continuous)を取得
GestureType gestureType;
ERROR_CHECK( gesture->get_GestureType( &gestureType ) );
switch( gestureType ){
case GestureType::GestureType_Discrete:
{
// Discrete Gestureの認識結果を取得
CComPtr<IDiscreteGestureResult> gestureResult;
ERROR_CHECK( gestureFrame->get_DiscreteGestureResult( gesture, &gestureResult ) );
// 検出結果を取得
BOOLEAN detected;
ERROR_CHECK( gestureResult->get_Detected( &detected ) );
if( !detected ){
break;
}
// 検出結果の信頼値を取得
float confidence;
ERROR_CHECK( gestureResult->get_Confidence( &confidence ) );
// 結果の描画
std::string discrete = gesture2string( gesture ) + " : Detected (" + std::to_string( confidence ) + ")";
discrete += " / " + std::to_string( trackingId );
cv::putText( colorImage, discrete, cv::Point( 50, 50 + offset ), font, 1.0f, colors[count], 2, CV_AA );
offset += 30;
break;
}
case GestureType::GestureType_Continuous:
{
// Continuous Gestureの認識結果を取得
CComPtr<IContinuousGestureResult> gestureResult;
ERROR_CHECK( gestureFrame->get_ContinuousGestureResult( gesture, &gestureResult ) );
// 進度を取得
float progress;
ERROR_CHECK( gestureResult->get_Progress( &progress ) );
// 結果の描画
std::string continuous = gesture2string( gesture ) + " : Progress " + std::to_string( progress );
continuous += " / " + std::to_string( trackingId );
cv::putText( colorImage, continuous, cv::Point( 50, 50 + offset ), font, 1.0f, colors[count], 2, CV_AA );
offset += 30;
break;
}
default:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment