Beispiel #1
0
void FaceApp::setup()
{	
	gl::enableAlphaBlending();
	
	mEnabledFace2d	= true;
	mEnabledFace3d	= true;
	mFrameRate		= 0.0f;
	mFullScreen		= false;

	mDevice = Kinect2::Device::create();
	mDevice->start();
	mDevice->enableFaceMesh();
	mDevice->connectBodyEventHandler( [ & ]( const Kinect2::BodyFrame frame )
	{
	} );
	mDevice->connectColorEventHandler( [ & ]( const Kinect2::ColorFrame frame )
	{
		mSurface = frame.getSurface();
	} );
		
	mParams = params::InterfaceGl::create( "Params", Vec2i( 230, 130 ) );
	mParams->addParam( "Frame rate",		&mFrameRate,			"", true );
	mParams->addParam( "Full screen",		&mFullScreen ).key( "f" );
	mParams->addParam( "2d face tracking",	&mEnabledFace2d ).key( "2" );
	mParams->addParam( "3d face tracking",	&mEnabledFace3d ).key( "3" );
	mParams->addButton( "Quit",				[ & ]() { quit(); } ,	"key=q" );
}
Beispiel #2
0
void BasicApp::setup()
{	
	gl::enable( GL_TEXTURE_2D );
	
	mFrameRate	= 0.0f;
	mFullScreen	= false;

	mDevice = Kinect2::Device::create();
	mDevice->start();
	mDevice->connectBodyIndexEventHandler( [ & ]( const Kinect2::BodyIndexFrame& frame )
	{
		mChannelBodyIndex = frame.getChannel();
	} );
	mDevice->connectColorEventHandler( [ & ]( const Kinect2::ColorFrame& frame )
	{
		mSurfaceColor = frame.getSurface();
	} );
	mDevice->connectDepthEventHandler( [ & ]( const Kinect2::DepthFrame& frame )
	{
		mChannelDepth = frame.getChannel();
	} );
	mDevice->connectInfraredEventHandler( [ & ]( const Kinect2::InfraredFrame& frame )
	{
		mChannelInfrared = frame.getChannel();
	} );
	
	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 100 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,			"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addButton( "Quit",			[ & ]() { quit(); } ,	"key=q" );
}
void PointCloudApp::setup()
{
    mCamUi = CameraUi(&mCam);

	gl::enable( GL_TEXTURE_2D );
	
	mFrameRate		= 0.0f;
	mFullScreen		= false;
	mTimeStamp		= 0L;
	mTimeStampPrev	= mTimeStamp;
	
	loadGlsl();

	mDevice = Kinect2::Device::create();
	mDevice->start();
	mDevice->connectColorEventHandler( [ & ]( const Kinect2::ColorFrame& frame )
	{
		mSurfaceColor	= frame.getSurface();
	} );
	mDevice->connectDepthEventHandler( [ & ]( const Kinect2::DepthFrame& frame )
	{
		mChannelDepth	= frame.getChannel();
		mTimeStamp		= frame.getTimeStamp();
	} );

	//////////////////////////////////////////////////////////////////////////////////////////////

	ivec2 sz = Kinect2::DepthFrame().getSize();
	vector<vec2> vertices;
	for ( int32_t x = 0; x < sz.x; ++x ) {
		for ( int32_t y = 0; y < sz.y; ++y ) {
			vertices.push_back( vec2( x, y ) / vec2( sz ) );
		}
	}

	gl::VboRef vbo = gl::Vbo::create( GL_ARRAY_BUFFER, vertices.size() * sizeof( vec2 ), &vertices[ 0 ], GL_STATIC_DRAW );

	geom::BufferLayout layout;
	layout.append( geom::Attrib::POSITION, 2, sizeof( vec2 ), 0 );
	vector<pair<geom::BufferLayout, gl::VboRef>> vertexArrayBuffers = { make_pair( layout, vbo ) };

	mVboMesh = gl::VboMesh::create( vertices.size(), GL_POINTS, vertexArrayBuffers );

	//////////////////////////////////////////////////////////////////////////////////////////////
	
	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 120 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,				"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addButton( "Load GLSL",	[ & ]() { loadGlsl(); },	"key=g" );
	mParams->addButton( "Quit",			[ & ]() { quit(); },		"key=q" );

	resize();
}