void WarpPerspective::draw( bool controls )
{
	// only draw grid while editing
	if( isEditModeEnabled() ) {
		gl::pushModelMatrix();
		gl::multModelMatrix( getTransform() );

		glLineWidth( 1.0f );
		glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );

		gl::ScopedColor color( Color::white() );
		for( int i = 0; i <= 1; i++ ) {
			float s = i / 1.0f;
			gl::drawLine( vec2( s * (float) mWidth, 0.0f ), vec2( s * (float) mWidth, (float) mHeight ) );
			gl::drawLine( vec2( 0.0f, s * (float) mHeight ), vec2( (float) mWidth, s * (float) mHeight ) );
		}

		gl::drawLine( vec2( 0.0f, 0.0f ), vec2( (float) mWidth, (float) mHeight ) );
		gl::drawLine( vec2( (float) mWidth, 0.0f ), vec2( 0.0f, (float) mHeight ) );

		gl::popModelMatrix();

		if( controls ) {
			// draw control points		
			for( int i = 0; i < 4; i++ )
				drawControlPoint( toVec2f( mDestination[i] ), i == mSelected );
		}
	}
}
Example #2
0
Vec2i mapDepthCoordToColor( const Vec2i& v, uint16_t depth, ICoordinateMapper* mapper )
{
    DepthSpacePoint depthSpacePoint;
    depthSpacePoint.X = (float)v.x;
    depthSpacePoint.Y = (float)v.y;

    ColorSpacePoint colorSpacePoint;
    long hr = mapper->MapDepthPointToColorSpace( depthSpacePoint, depth, &colorSpacePoint );
    if ( SUCCEEDED( hr ) ) {
        return Vec2i( toVec2f( colorSpacePoint ) );
    }
    return Vec2i();
}
Example #3
0
Vec2i mapBodyCoordToDepth( const Vec3f& v, ICoordinateMapper* mapper )
{
    CameraSpacePoint cameraSpacePoint;
    cameraSpacePoint.X = v.x;
    cameraSpacePoint.Y = v.y;
    cameraSpacePoint.Z = v.z;

    DepthSpacePoint depthSpacePoint;
    long hr = mapper->MapCameraPointToDepthSpace( cameraSpacePoint, &depthSpacePoint );
    if ( SUCCEEDED( hr ) ) {
        return Vec2i( toVec2f( depthSpacePoint ) );
    }
    return Vec2i();
}
Example #4
0
Channel16u mapDepthFrameToColor( const Channel16u& depth, ICoordinateMapper* mapper )
{
    size_t numPoints = depth.getWidth() * depth.getHeight();
    Channel16u channel( depth.getWidth(), depth.getHeight() );
    vector<ColorSpacePoint> colorSpacePoints( numPoints );
    long hr = mapper->MapDepthFrameToColorSpace( (UINT)numPoints, depth.getData(), numPoints, &colorSpacePoints[ 0 ] );
    if ( SUCCEEDED( hr ) ) {
        Channel16u::Iter iter = channel.getIter();
        size_t i = 0;
        while ( iter.line() ) {
            while ( iter.pixel() ) {
                Vec2i pos = Vec2i( toVec2f( colorSpacePoints[ i ] ) );
                uint16_t v = 0x0000;
                if ( pos.x >= 0 && pos.x < depth.getWidth() && pos.y >= 0 && pos.y < depth.getHeight() ) {
                    v = depth.getValue( pos );
                }
                iter.v() = v;
            }
        }
    }
    return channel;
}