Ejemplo n.º 1
0
void bordaiApp::setup() {
	mParams = params::InterfaceGl("bordai", Vec2i(300, 175));
	mParams.addParam("Screen width", &mWindowSize.x, "", true);
	mParams.addParam("Screen height", &mWindowSize.y, "", true);
	mParams.addParam("Camera width", &mCameraLensSize.x, "min=128 max=1024 step=64 keyIncr=W keyDecr=w");
	mParams.addParam("Camera height", &mCameraLensSize.y, "min=128 max=1024 step=64 keyIncr=H keyDecr=h");
	mParams.addSeparator();
	mParams.addText("Press space to apply new camera resolution");
	mParams.addText("Press 'p' to pause/play camera");
	mParams.addSeparator();
	mParams.addParam("Framerate", &mFrameRate, "min=5.0 max=70.0 step=5.0 keyIncr=+ keyDecr=-");
	
	mHaarDetector = HaarDetector( getResourcePath( "haarcascade_frontalface_alt2.xml" ) );
	mCamera.startCapturing(mCameraLensSize.x, mCameraLensSize.y);
}
void DelaunayMeshMaker::setup()
{
	mSurface = loadImage( app::loadAsset( "texture0.jpg" ) );
	
	int width = mSurface.getWidth();
	int height = mSurface.getHeight();
	app::setWindowSize( width, height );

	mFbo = gl::Fbo( width, height, false );

	mBorderPoints.push_back( Vec2f::zero() );
	mBorderPoints.push_back( Vec2f( (float)width, 0 ) );
	mBorderPoints.push_back( Vec2f( (float)width ,(float)height ) );
	mBorderPoints.push_back( Vec2f( 0 ,(float)height ) );

	mMesh.clear();

	mParams = params::InterfaceGl( "Parameters", Vec2i( 300, 250 ) );
	mParams.addParam( "Alpha", &mAlpha, "max=1.0 min=0.0 step=0.005" );
	mParams.addParam( "Blend", &mBlend );
	mParams.addParam( "Phong Shading", &mApplyPhongShading );
	mParams.addParam( "Depth Offset", &mDepthOffset, "step=0.1" );
	mParams.addParam( "Draw wireframe", &mDrawWireframe );
	
	mParams.addSeparator();
	mParams.addText("Edge detection");
	mParams.addParam( "Edge detection scale down", &mScaleDown, "min=1" );
	mParams.addParam( "Minimum threshold", &mCannyMinThreshold, "min=0.0f" );
	mParams.addParam( "Maximum threshold", &mCannyMaxThreshold, "min=0.0f" );

	mParams.addSeparator();
	mParams.addButton( "Tesselate", std::bind( &DelaunayMeshMaker::tesselate, this ) );

	mScaleDown			= 8;
	mScaleDownPrev		= mScaleDown;
	mCannyMinThreshold	= 60.0;
	mCannyMaxThreshold	= 70.0;
	mAlpha				= 0.0f;
	mBlend				= false;
	mApplyPhongShading	= false;
	mDrawWireframe		= false;
	mDepthOffset		= 0.0f;
	mPrevDepthOffset	= mDepthOffset;
	mPrevBlend			= mBlend;

	mPhongShader = gl::GlslProg( loadAsset("phong_vert.glsl"), loadAsset("phong_frag.glsl") );

	mEdgeDetectSurface = edgeDetect( Surface8u( mSurface ), mCannyMinThreshold, mCannyMaxThreshold, mScaleDownPrev );

	mTesselator = Tesselator::makeTesselator();
	mTesselator->sDone.connect( boost::bind( &DelaunayMeshMaker::onTesselationDone, this ) );
}
Ejemplo n.º 3
0
void FxApp::setupParams()
{
	mParams.clear();

	mParams.addParam( "Effect", mEffectNames, &mCurrentEffect );

	mParams.addSeparator();

	mParams.addText( mEffects[ mCurrentEffect ]->getName() );
	mEffects[ mCurrentEffect ]->addToParams( mParams );

	mParams.addSeparator();
	mParams.addParam( "Fps", &mFps, "", true );
}
Ejemplo n.º 4
0
void UserApp::setup()
{
    mShapeDetection = ShapeDetection();
    
    //	mBones.push_back( Bone( nite::JOINT_HEAD,			nite::JOINT_NECK ) );
    //	mBones.push_back( Bone( nite::JOINT_LEFT_SHOULDER,	nite::JOINT_LEFT_ELBOW ) );
    //	mBones.push_back( Bone( nite::JOINT_LEFT_ELBOW,		nite::JOINT_LEFT_HAND ) );
    //	mBones.push_back( Bone( nite::JOINT_RIGHT_SHOULDER, nite::JOINT_RIGHT_ELBOW ) );
    //	mBones.push_back( Bone( nite::JOINT_RIGHT_ELBOW,	nite::JOINT_RIGHT_HAND ) );
    //	mBones.push_back( Bone( nite::JOINT_LEFT_SHOULDER,	nite::JOINT_RIGHT_SHOULDER ) );
    //	mBones.push_back( Bone( nite::JOINT_LEFT_SHOULDER,	nite::JOINT_TORSO ) );
    //	mBones.push_back( Bone( nite::JOINT_RIGHT_SHOULDER, nite::JOINT_TORSO ) );
    //	mBones.push_back( Bone( nite::JOINT_TORSO,			nite::JOINT_LEFT_HIP ) );
    //	mBones.push_back( Bone( nite::JOINT_TORSO,			nite::JOINT_RIGHT_HIP ) );
    //	mBones.push_back( Bone( nite::JOINT_LEFT_HIP,		nite::JOINT_RIGHT_HIP ) );
    //	mBones.push_back( Bone( nite::JOINT_LEFT_HIP,		nite::JOINT_LEFT_KNEE ) );
    //	mBones.push_back( Bone( nite::JOINT_LEFT_KNEE,		nite::JOINT_LEFT_FOOT ) );
    //	mBones.push_back( Bone( nite::JOINT_RIGHT_HIP,		nite::JOINT_RIGHT_KNEE ) );
    //	mBones.push_back( Bone( nite::JOINT_RIGHT_KNEE,		nite::JOINT_RIGHT_FOOT ) );
    
    // POINTS
    mBones.push_back( Bone( nite::JOINT_HEAD,			nite::JOINT_HEAD ) );                //0
    mBones.push_back( Bone( nite::JOINT_NECK,			nite::JOINT_NECK ) );                //1
    mBones.push_back( Bone( nite::JOINT_LEFT_SHOULDER,	nite::JOINT_LEFT_SHOULDER ) );       //2
    mBones.push_back( Bone( nite::JOINT_LEFT_ELBOW,     nite::JOINT_LEFT_ELBOW ) );          //3
    mBones.push_back( Bone( nite::JOINT_LEFT_HAND,		nite::JOINT_LEFT_HAND ) );           //4
    mBones.push_back( Bone( nite::JOINT_RIGHT_SHOULDER, nite::JOINT_RIGHT_SHOULDER ) );      //5
    mBones.push_back( Bone( nite::JOINT_RIGHT_ELBOW,    nite::JOINT_RIGHT_ELBOW ) );         //6
    mBones.push_back( Bone( nite::JOINT_RIGHT_HAND,     nite::JOINT_RIGHT_HAND ) );          //7
    mBones.push_back( Bone( nite::JOINT_TORSO,          nite::JOINT_TORSO ) );               //8
    mBones.push_back( Bone( nite::JOINT_LEFT_HIP,		nite::JOINT_LEFT_HIP ) );            //9
    mBones.push_back( Bone( nite::JOINT_LEFT_KNEE,		nite::JOINT_LEFT_KNEE ) );          //10
    mBones.push_back( Bone( nite::JOINT_LEFT_FOOT,		nite::JOINT_LEFT_FOOT ) );          //11
    mBones.push_back( Bone( nite::JOINT_RIGHT_HIP,		nite::JOINT_RIGHT_HIP ) );          //12
    mBones.push_back( Bone( nite::JOINT_RIGHT_KNEE,		nite::JOINT_RIGHT_KNEE ) );         //13
    mBones.push_back( Bone( nite::JOINT_RIGHT_FOOT,		nite::JOINT_RIGHT_FOOT ) );         //14
    
    // DISTANCE LINES
    
    // hand to hand
    mBones.push_back( Bone( nite::JOINT_LEFT_HAND,	nite::JOINT_RIGHT_HAND ) );
    
    // limbs
    mBones.push_back( Bone( nite::JOINT_LEFT_HAND,	nite::JOINT_TORSO ) );
    mBones.push_back( Bone( nite::JOINT_RIGHT_HAND,	nite::JOINT_TORSO ) );
    mBones.push_back( Bone( nite::JOINT_LEFT_FOOT,	nite::JOINT_RIGHT_HAND ) );
    mBones.push_back( Bone( nite::JOINT_RIGHT_FOOT,	nite::JOINT_LEFT_HAND ) );
    
    //surrounding body
    mBones.push_back( Bone( nite::JOINT_RIGHT_FOOT,	nite::JOINT_LEFT_FOOT ) );
    mBones.push_back( Bone( nite::JOINT_LEFT_FOOT,	nite::JOINT_LEFT_HAND ) );
    mBones.push_back( Bone( nite::JOINT_LEFT_HAND,	nite::JOINT_HEAD ) );
    mBones.push_back( Bone( nite::JOINT_HEAD,	nite::JOINT_RIGHT_HAND ) );
    mBones.push_back( Bone( nite::JOINT_RIGHT_HAND,	nite::JOINT_RIGHT_FOOT) );
    
    mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 45.0f, 1.0f, 5000.0f );
    mCamera.lookAt( Vec3f::zero(), Vec3f::zAxis(), Vec3f::yAxis() );
    
    mDeviceManager = OpenNI::DeviceManager::create();
    try {
        mDevice = mDeviceManager->createDevice( OpenNI::DeviceOptions().enableUserTracking() );
    } catch ( OpenNI::ExcDeviceNotAvailable ex ) {
        console() << "exception with openni: " << ex.what() << endl;
        quit();
        return;
    }
    
    mDevice->getUserTracker().setSkeletonSmoothingFactor( 0.5f );
    mDevice->connectUserEventHandler( &UserApp::onUser, this );
    mDevice->start();
    
    // vector of trails
    for( int i=0; i<15; i++ ){
        mTrails.push_back(TrailPoint());
        mShowJoints.push_back(false);
//        mShowJoints[i] = false;
    }
    mShowJoints[0] = true;
    mColors.push_back( Color( 0.0f, 0.75f, 1.0f ) );
    mColors.push_back( Color( 1.0f, 0.08f, 0.58f) );
    mColors.push_back( Color( 1.0f, 0.0f, 1.0f ) );
    mColors.push_back( Color( 0.0f, 1.0f, 1.0f ) );
    mColors.push_back( Color( 0.0f, 1.0f, 0.0f ) );
    mColors.push_back( Color( 0.48f, 0.41f, 0.93f ) );
    mColors.push_back( Color( 0.6f, 0.2f, 0.8f ) );
    mColors.push_back( Color( 0.12f, 0.56f, 1.0f ) );
    mColors.push_back( Color( 0.0f, 0.81f, 0.82f ) );
    mColors.push_back( Color( 0.75f, 0.75f, 0.75f ) );
    mColors.push_back( Color( 0.54f, 0.17f, 0.87f ) );
    mColors.push_back( Color( 1.0f, 0.08f, 0.58f ) );
    mColors.push_back( Color( 1.0f, 1.0f, 1.0f ) );
    mColors.push_back( Color( 0.29f, 0.0f, 0.51f ) );
    mColors.push_back( Color( 0.0f, 0.0f, 1.0f ) );
    
    // params window
    mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 500 ), ColorA( 0.0f, 0.0f, 0.0f, 0.5f ) );
    mParams.addParam( "On Balance", &mUseBalance );
    mParams.addParam( "Negative Space", &mShowNegativeSpace );
    mParams.addParam( "Distance Lines", &mShowDistanceLines );
    
    
    //mParams.addText("the distance between A and B is" , dist);
    

    mParams.addText( " ");
    mParams.addText( "Follow joints:");
    
    vector<string> joints = { "Head", "Neck", "Left Shoulder", "Left Elbow", "Left Hand", "Right Shoulder", "Right Elbow", "Right Hand", "Torso", "Left Hip", "Left Knee", "Left Foot", "Right Hip",  "Right Knee",  "Right Foot" };
    for ( int i=0; i<joints.size(); i++ ) {
        Boolean *thing = &mShowJoints[i];
        mParams.addParam(joints[i], &mShowJoints[i]);
    }
    
}
Ejemplo n.º 5
0
void reflection_animationApp::setup()
{
    
	// STRUCTURE
	
	m_shapeDims = Vec3f(50, 75, 50);
	m_numlevels = 12;
    m_incr = 2;
	
    m_shapeType = PYRAMID;
    
    initShape();
	cout << m_structure.m_shapes.size() << endl;
    
    // DISPLAY
    
    m_showInterface = true;
    m_recording = false;
    
    m_path = getHomeDirectory() / "Desktop/"; 
    
	m_showColour = true;
    m_renderMode = ALPHA;
    
    m_contrast = 4.0f;
    m_alpha = .45f;
    
    m_face1Display = ACTIVE;
    m_face2Display = DICHROIC1;
    m_face3Display = GLASS;
    m_face4Display = NONE;
    
    m_dichroic1Colour = Color(0.3f, 0.8f, 1.0f);
    m_dichroic2Colour = Color(1.0f, 0.8f, 0.3f);
	
    // ANIMATION
    
    m_aniMode = VIDEO;
    
    // radar
    m_interval = 360;
    m_frontarea = 1.5f;
    m_backarea  = 6.0f;
    
	// GUI
    
	m_params = params::InterfaceGl( "Geometry/Animation Parameters [press TAB to hide]", Vec2i( 400, 600 ) );
	
    // render
    m_params.addText( "render", "label=`Render`" );
	m_params.addSeparator();
    vector<string> rstrs; rstrs.push_back("ALPHA"); rstrs.push_back("ADDITIVE"); rstrs.push_back("MULTIPLY");
    m_params.addParam( "Render Mode", rstrs, (int*)&m_renderMode );
    m_params.addParam( "Use Colour", &m_showColour );
    m_params.addParam( "Alpha", &m_alpha, "min=0.001 max=2.0 step=0.1" );
	m_params.addParam( "Contrast", &m_contrast, "min=0.001 max=5.0 step=0.1" );
	m_params.addParam( "Dichroic Colour 1", &m_dichroic1Colour );
	m_params.addParam( "Dichroic Colour 2", &m_dichroic2Colour );
    m_params.addText( "emptyline1", "label=` `" );
    
    // structure
	m_params.addText( "structure", "label=`Structure`" );
	m_params.addSeparator();
    vector<string> dstrs; dstrs.push_back("ACTIVE"); dstrs.push_back("DICHROIC1"); dstrs.push_back("DICHROIC2"); dstrs.push_back("GLASS"); dstrs.push_back("NONE");
	m_params.addParam( "Face 1 Display mode", dstrs, (int*)&m_face1Display );
    m_params.addParam( "Face 2 Display mode", dstrs, (int*)&m_face2Display );
    m_params.addParam( "Face 3 Display mode", dstrs, (int*)&m_face3Display );
    m_params.addParam( "Face 4 Display mode", dstrs, (int*)&m_face4Display );
    m_params.addText( "emptyline2", "label=` `" );
    
    // generate shape
    m_params.addText( "generate", "label=`Generate`" );
	m_params.addSeparator();
    vector<string> sstrs; sstrs.push_back("PYRAMID"); sstrs.push_back("TETRAHEDRON"); sstrs.push_back("HOLLOW PYRAMID");
	m_params.addParam( "Shape", sstrs, (int*)&m_shapeType );
    m_params.addParam( "Number Of Levels", &m_numlevels );
    m_params.addParam( "Vertical Interval", &m_incr );
    m_params.addParam( "Shape Dimensions", &m_shapeDims );
    m_params.addButton( "Recreate Shape", std::bind( &reflection_animationApp::initShape, this ) );
    m_params.addText( "emptyline3", "label=` `" );
    
    // animation
    m_params.addText( "animation", "label=`Animation`" );
	m_params.addSeparator();
    vector<string> astrs; astrs.push_back("STATIC"); astrs.push_back("RADAR"); astrs.push_back("VIDEO"); astrs.push_back("VIDEO_RADAR");
	m_params.addParam( "Animation Mode", astrs, (int*)&m_aniMode );
    m_params.addParam( "Interval", &m_interval );
    m_params.addParam( "Size (front)", &m_frontarea );
    m_params.addParam( "Size (tail)", &m_backarea );
    
    m_params.addButton( "Recreate Shape", std::bind( &reflection_animationApp::initShape, this ) );
    
	
	// CAMERA/PERSPECTIVE (not updated anymore -> mayacam)

	m_cameraDistance = 800.0f;
    
    m_eye        = Vec3f( 0.0f, 0.0f, m_cameraDistance );
	m_center     = Vec3f::zero();
	m_up         = Vec3f::yAxis();
    
    CameraPersp cam;
    
    cam.setEyePoint(m_eye);
    cam.setCenterOfInterestPoint(m_center);
    cam.setWorldUp(m_up);
    cam.setPerspective(60.0, getWindowAspectRatio(), 5.0, 5000.0);
    m_mayaCam.setCurrentCam( cam );
    
	
	// CAPTURE/VIDEO/INPUT
    
    m_surface = Surface8u(600, 400, true);
    
	vector<Capture::DeviceRef> devices( Capture::getDevices() );
	for( vector<Capture::DeviceRef>::const_iterator deviceIt = devices.begin(); deviceIt != devices.end(); ++deviceIt ) {
		Capture::DeviceRef device = *deviceIt;
		console() << "Found Device " << device->getName() << " ID: " << device->getUniqueId() << std::endl;
		try {
			if( device->checkAvailable() ) {

				m_capture.push_back( Capture( 600, 400, device ) );
				m_capture.back().start();
				
				// placeholder texture
				m_textures.push_back( gl::Texture() );
			}
			else
				console() << "device is NOT available" << std::endl;
		}
		catch( CaptureExc & ) {
			console() << "Unable to initialize device: " << device->getName() << endl;
		}
	}
	
    // these should actually only be updated on change --> pointers to parameters
    
    DisplayMode* faceModesArr[] = {
        &m_face1Display, &m_face2Display, &m_face3Display, &m_face4Display
    };
    vector<DisplayMode*> p_faceModes(faceModesArr, faceModesArr+4);
    
    m_structure.setMaterialSettings( p_faceModes, &m_showColour, &m_alpha, &m_contrast );
    m_structure.setAnimationSettings( &m_aniMode );
    m_structure.setRadarSettings( &m_interval, &m_frontarea, &m_backarea);
    
    
}