void LocationApp::setup() { // Define properties mHeading = 0.0f; timeline().apply( &mRotationAngle, 0.0f, (float)(2 * M_PI), 8.0f ).loop(); timeline().apply( &mDotRadius, 0.0f, 0.1f, 0.5f ).loop(); LocationManager::enable(); LocationManager::getSignalLocationChanged().connect( std::bind( &LocationApp::locationChanged, this, std::_1 ) ); #if defined( CINDER_COCOA_TOUCH ) LocationManager::getSignalHeadingChanged().connect( std::bind( &LocationApp::headingChanged, this, std::_1 ) ); #endif // Load globe texture, setFrameRate( 60.0f ); mTexture = gl::Texture( loadImage( loadResource( RES_EARTH_JPG ) ) ); mTexture.setFlipped( true ); // Set up view gl::enable( GL_TEXTURE_2D ); gl::enableAlphaBlending(); // Set up light mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 ); mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() ); mLight->setAmbient( ColorAf::gray( 0.843f ) ); mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) ); mLight->enable(); // Build the heading arrow float size = 80.0f; mArrow.moveTo( Vec2f( 0.0f, -size * 0.5f ) ); mArrow.lineTo( Vec2f( size * 0.5f, size * 0.5f ) ); mArrow.lineTo( Vec2f( 0.0f, size * 0.25f ) ); mArrow.lineTo( Vec2f( -size * 0.5f, size * 0.5f ) ); mArrow.close(); }
void NIUserMaskApp::update() { if ( mNI.checkNewVideoFrame() ) { Surface8u maskSurface = mNIUserTracker.getUserMask(); cv::Mat cvMask, cvMaskFiltered; cvMask = toOcv( Channel8u( maskSurface ) ); cv::blur( cvMask, cvMaskFiltered, cv::Size( mBlurAmt, mBlurAmt ) ); cv::Mat dilateElm = cv::getStructuringElement( cv::MORPH_RECT, cv::Size( mDilateAmt, mDilateAmt ) ); cv::Mat erodeElm = cv::getStructuringElement( cv::MORPH_RECT, cv::Size( mErodeAmt, mErodeAmt ) ); cv::erode( cvMaskFiltered, cvMaskFiltered, erodeElm, cv::Point( -1, -1 ), 1 ); cv::dilate( cvMaskFiltered, cvMaskFiltered, dilateElm, cv::Point( -1, -1 ), 3 ); cv::erode( cvMaskFiltered, cvMaskFiltered, erodeElm, cv::Point( -1, -1 ), 1 ); cv::blur( cvMaskFiltered, cvMaskFiltered, cv::Size( mBlurAmt, mBlurAmt ) ); cv::threshold( cvMaskFiltered, cvMaskFiltered, mThres, 255, CV_THRESH_BINARY); vector< vector< cv::Point > > contours; cv::findContours( cvMaskFiltered, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE ); mShape.clear(); for ( vector< vector< cv::Point > >::const_iterator it = contours.begin(); it != contours.end(); ++it ) { vector< cv::Point >::const_iterator pit = it->begin(); if ( it->empty() ) continue; mShape.moveTo( fromOcv( *pit ) ); ++pit; for ( ; pit != it->end(); ++pit ) { mShape.lineTo( fromOcv( *pit ) ); } mShape.close(); } } }