Example #1
0
void RogersGuiApp::keyDown( KeyEvent event ) {
	switch(event.getChar()) {				
		case 'd': gui->dump(); break; //prints values of all the controls to the console			
		case 'l': gui->load(CONFIG_FILE); break;
		case 's': gui->save(CONFIG_FILE); break;					
	}
	switch(event.getCode()) {
		case KeyEvent::KEY_ESCAPE: quit(); break;
	}
}
void GesichtertauschApp::keyDown( KeyEvent pEvent ) {
    switch(pEvent.getChar()) {				
        case 'd': mGui->dump(); break;
        case 'l': mGui->load(getResourcePath(RES_SETTINGS)); break;
        case 's': mGui->save(getResourcePath(RES_SETTINGS)); break;
//        case 'm':
//            CGDirectDisplayID mDisplayID = getSettings().getDisplay()->getCGDirectDisplayID();
//            CGDisplayConfigRef pConfigRef;
//            CGBeginDisplayConfiguration (&pConfigRef);
//            CGConfigureDisplayOrigin (pConfigRef,
//                                      mDisplayID,
//                                      -100, 0);
//            CGCompleteDisplayConfiguration (pConfigRef, kCGConfigureForAppOnly);
//            break;
    }
    switch(pEvent.getCode()) {
        case KeyEvent::KEY_ESCAPE:  setFullScreen( false ); quit(); break;
        case KeyEvent::KEY_SPACE: mGui->setEnabled(!mGui->isEnabled());break;
    }
}
void ScheinrieseApp::keyDown( KeyEvent event )
{
    switch(event.getChar()) {
    case 'd':
        mGui->dump();
        break;
    case 'l':
        mGui->load(getResourcePath(RES_SETTINGS));
        break;
    case 's':
        mGui->save(getResourcePath(RES_SETTINGS));
        break;
    }
    switch(event.getCode()) {
    case KeyEvent::KEY_ESCAPE:
        quit();
        break;
    case KeyEvent::KEY_SPACE:
        mGui->setEnabled(!mGui->isEnabled());
    }
}
Example #4
0
void BasicApp::setup() {
	gui = new SimpleGUI(this);
	gui->lightColor = ColorA(1, 1, 0, 1);	
	gui->addLabel("CONTROLS");
	gui->addParam("Rotation", &rotation, 0, 360, 0);
	gui->addParam("Size", &size, 100, 600, 200); 	
	gui->addParam("Color", &color, ColorA(0,0.5,1,0.5), SimpleGUI::RGB); //use R,G,B,A sliders
	gui->addSeparator();
	gui->addLabel("OPTIONS");
	gui->addParam("Auto Rotation", &autoRotation, false); 
	gui->addSeparator();	
	gui->addLabel("RENDER TYPE");
	gui->addParam("Fill", &fill, true, RENDER_TYPE_GROUP); //if we specify group id, we create radio button set
	gui->addParam("Stroke", &stroke, false, RENDER_TYPE_GROUP); //i.e. only one of the buttons can be active at any time
	
	gui->load(CONFIG_FILE); //we load settings after specifying all the 
	                       //params because we need to know their name and type
	
	timer.start();
	prevTime = timer.getSeconds();
}
void GesichtertauschApp::setup() {
    
    console() << "+++ Gesichtertausch (PID " << getpid() << ")." << endl;
    
    mTime = 0.0;
    mSerialID = 0;
    FACE_COLOR_UNO = ColorA(0, 1, 1, 1);
    FACE_COLOR_DUO = ColorA(1, 0, 0, 1);
    BACKGROUND_IMAGE_COLOR = ColorA(1, 1, 1, 1);
    
    /* watchdog */
    mWatchdogHost = "localhost";
	mWatchdogPort = 8080;
	mWatchdogSender.setup(mWatchdogHost, mWatchdogPort);
    mWatchdogCounter = 0.0;
    mWatchdogInterval = 2.5;
    
    /* shader */
    try {
		mShader = gl::GlslProg( loadResource( RES_PASSTHRU_VERT ), loadResource( RES_BLUR_FRAG ) );
	}
	catch( gl::GlslProgCompileExc &exc ) {
		console() << "Shader compile error: " << std::endl;
		console() << exc.what();
	}
	catch( ... ) {
		console() << "Unable to load shader" << std::endl;
	}
    
    /* settings */
    mGui = new SimpleGUI(this);
    mGui->addParam("WINDOW_WIDTH", &WINDOW_WIDTH, 0, 2048, 640);
    mGui->addParam("WINDOW_HEIGHT", &WINDOW_HEIGHT, 0, 2048, 480);
    mGui->addParam("CAMERA_WIDTH", &CAMERA_WIDTH, 0, 2048, 640);
    mGui->addParam("CAMERA_HEIGHT", &CAMERA_HEIGHT, 0, 2048, 480);
    mGui->addParam("DETECTION_WIDTH", &DETECTION_WIDTH, 0, 2048, 320);
    mGui->addParam("DETECTION_HEIGHT", &DETECTION_HEIGHT, 0, 2048, 240);
    mGui->addParam("FULLSCREEN", &FULLSCREEN, false, 0);
    mGui->addParam("TRACKING", &TRACKING, 0, 1, 0);
    //
    mGui->addParam("FRAME_RATE", &FRAME_RATE, 1, 120, 30);
    mGui->addParam("MIN_TRACKING_DISTANCE", &MIN_TRACKING_DISTANCE, 1, 100, 50);
    mGui->addParam("TIME_BEFOR_IDLE_DEATH", &TIME_BEFOR_IDLE_DEATH, 0, 10, 0.5);
    mGui->addParam("MIN_LIFETIME_TO_VIEW", &MIN_LIFETIME_TO_VIEW, 0, 10, 1.0);
    mGui->addParam("ENABLE_SHADER", &ENABLE_SHADER, 0, 1, 0);
    mGui->addParam("FACE_COLOR_UNO", &FACE_COLOR_UNO, ColorA(0, 1, 1, 1), SimpleGUI::RGB);
    mGui->addParam("FACE_COLOR_DUO", &FACE_COLOR_DUO, ColorA(1, 1, 1, 1), SimpleGUI::RGB);
    mGui->addParam("BACKGROUND_IMAGE_COLOR", &BACKGROUND_IMAGE_COLOR, ColorA(1, 1, 1, 1), SimpleGUI::RGB);
    mGui->addParam("FACE_BORDER_SCALE", &FACE_BORDER_SCALE, 0, 3, 0.7);
    mGui->addParam("FACE_FADE_BORDER_SCALE", &FACE_FADE_BORDER_SCALE, 1, 2, 1.4);
            
    /* clean up controller window */
    mGui->getControlByName("WINDOW_WIDTH")->active=false;
    mGui->getControlByName("WINDOW_HEIGHT")->active=false;
    mGui->getControlByName("CAMERA_WIDTH")->active=false;
    mGui->getControlByName("CAMERA_HEIGHT")->active=false;
    mGui->getControlByName("DETECTION_WIDTH")->active=false;
    mGui->getControlByName("DETECTION_HEIGHT")->active=false;
    mGui->getControlByName("FULLSCREEN")->active=false;
    mGui->getControlByName("TRACKING")->active=false;
    mGui->getControlByName("BACKGROUND_IMAGE_COLOR")->active=false;
    mGui->getControlByName("BACKGROUND_IMAGE_COLOR")->active=false;
    
    mGui->load(getResourcePath(RES_SETTINGS));
    mGui->setEnabled(false);
    
    setWindowSize( WINDOW_WIDTH, WINDOW_HEIGHT );
    setFullScreen( FULLSCREEN );
    if (FULLSCREEN) {
        hideCursor();
//        switch_resolution (WINDOW_WIDTH, WINDOW_HEIGHT, 60.0);
    }
    
    mFont = Font(loadResource("pf_tempesta_seven.ttf"), 8);

    /* setting up capture device */
    mCameraTexture = gl::Texture(CAMERA_WIDTH, CAMERA_HEIGHT);
    switch (TRACKING) {
        case 0:
            mFaceDetection = new FeatureDetectionCinder();
            break;
#ifdef COMPILE_CAPTURE_FIREFLY
        case 1:
            mFaceDetection = new FeatureDetectionFireFly();
            break;
#endif
#ifdef COMPILE_CAPTURE_OPENCV
        case 2:
            mFaceDetection = new FeatureDetectionOpenCV();
            break;
#endif
        default:
            console() << "### choosing default tracking method." << endl;
            mFaceDetection = new FeatureDetectionCinder();
            break;
    }

    mGui->addParam("DETECT_FLAGS",&(mFaceDetection->DETECT_FLAGS), CV_HAAR_DO_CANNY_PRUNING, CV_HAAR_DO_ROUGH_SEARCH, CV_HAAR_DO_CANNY_PRUNING);
    mGui->addParam("DETECT_SCALE_FACTOR",&(mFaceDetection->DETECT_SCALE_FACTOR), 1.1, 5, 1.2);
    mGui->addParam("DETECT_MIN_NEIGHBORS",&(mFaceDetection->DETECT_MIN_NEIGHBORS), 1, 20, 2);

    mGui->addParam("CAMERA_EXPOSURE", &(mFaceDetection->CAMERA_EXPOSURE), 0, 255, 20);
    mGui->addParam("CAMERA_SHUTTER", &(mFaceDetection->CAMERA_SHUTTER), 0, 255, 200);
    mGui->addParam("CAMERA_BRIGHTNESS", &(mFaceDetection->CAMERA_BRIGHTNESS), 0, 255, 166);
    mGui->addParam("CAMERA_GAIN", &(mFaceDetection->CAMERA_GAIN), 0, 255, 17);

    mGui->load(getResourcePath(RES_SETTINGS)); // HACK this is quite stupid, but we have a catch 22 here ...
    mFaceDetection->setup(CAMERA_WIDTH, 
                          CAMERA_HEIGHT, 
                          DETECTION_WIDTH, 
                          DETECTION_HEIGHT,
                          0);
    mGui->dump();
    
    mGui->addSeparator();
    mFaceOut = mGui->addLabel("");
    mFPSOut = mGui->addLabel("");
}
Example #6
0
void RogersGuiApp::setup() {
    rotation = 0;
    screenshot = gl::Texture(getWindowWidth(), getWindowHeight()); //uninitialized texture with random pixels from GPU memory
	IntVarControl *ic;
	BoolVarControl *bc;
	PanelControl *pc;
	ByteVarControl *btc;
	FlagVarControl *fc;
	aString = "whatever";
	
    gui = new SimpleGUI(this);
	gui->lightColor = ColorA(1, 1, 0, 1);
	gui->addColumn();
	gui->addLabel("> READ ONLY");
    gui->addSeparator();
	gui->addLabel("READONLY");
	gui->addParam("String", &aString);						// !NEW! Update aString will update label 
	gui->addParam("Window Width", &windowWidth, 0, 1920, getWindowWidth())->setReadOnly();		// !NEW! No slider, just value
	gui->addParam("Window Height", &windowHeight, 0, 1080, getWindowHeight())->setReadOnly();	// !NEW! No slider, just value
	gui->addParam("FPS", &FPS, 0, 60, 0)->setReadOnly();	// !NEW! No slider, just value
    gui->addSeparator();
    
	// Textures
	gui->addLabel("> TEXTURES");
    gui->addSeparator();
    takeScreenshotButton = gui->addButton("Take screenshot");    
	takeScreenshotButton->registerClick(this, &RogersGuiApp::takeScreenshotButtonClick);    
    screenshotTextureControl = gui->addParam("Screenshot", &screenshot);
	screenshotTextureControl->refreshRate = 0.0;		// !NEW! let's refresh manually
	//screenshotTextureControl->refreshRate = 0.1;		// !NEW! use this for movies or syphon
    //takeScreenshotButton->unregisterClick(cbTakeScreenshotButtonClick);
    gui->addSeparator();
    gui->addParam("Null Texture example", &nullTex);	// !NEW! Null textures will be marked so
	
    //
	// ROGER:: From Grouping example
	gui->addColumn();
	gui->addLabel("> CONTROLS");
    gui->addSeparator();
    gui->addButton("Restart Animation")->registerClick(this, &RogersGuiApp::restartButtonClick);
	bc = gui->addParam("Auto Rotation ON", &autoRotation, true);
	bc->nameOff = "Auto Rotation OFF";	// !NEW! Alternative label when OFF
	gui->addParam("Rotation", &rotation, 0, 360, 0)->setDisplayValue();
	gui->addParam("Size", &size, 100, 600, 200)->setDisplayValue();
	gui->addParam("Background", &colorBack, Color(0.1, 0.1, 0.5), SimpleGUI::RGB); //use R,G,B,A sliders
	gui->addParam("Color", &color, ColorA(1, 0.2, 0.2, 0.1), SimpleGUI::RGB); //use R,G,B,A sliders
	gui->addParam("HSV", &colorBackHSV, Color(0.1, 0.1, 0.5), SimpleGUI::HSV);
	gui->addParam("HSV+A", &colorHSV, ColorA(1, 0.2, 0.2, 0.1), SimpleGUI::HSV);
    gui->addSeparator();
	gui->addLabel("RENDER TYPE");
	gui->addParam("Fill", &fill, true, RENDER_TYPE_GROUP); //if we specify group id, we create radio button set
	bc = gui->addParam("Stroke", &stroke, false, RENDER_TYPE_GROUP); //i.e. only one of the buttons can be active at any time	
	pc = gui->addPanel();
	bc->switchPanel( pc );		// !NEW! Automatically open/close a panel
	gui->addParam("Thickness", &thickness, 1, 10);
	
	//
	// LIST CONTROL
	gui->addColumn();
	gui->addLabel("> LISTS");
    gui->addSeparator();
    gui->addButton("Increase List")->registerClick(this, &RogersGuiApp::addToList);
    gui->addButton("Decrease List")->registerClick(this, &RogersGuiApp::removeFromList);
	valueLabels[0] = "val 0";
	valueLabels[1] = "val 1";
	valueLabels[2] = "val 2";
    gui->addSeparator();
	theDropDownControl = gui->addParamDropDown("Drop-Down List", &listVal, valueLabels);	// !NEW! Drop-Down control
    gui->addSeparator();
	theListControl = gui->addParamList("Explicit List", &listVal, valueLabels);				// !NEW! List control
    gui->addSeparator();
    gui->addLabel("just a label");
	
	//
	// INTS CONTROL
	gui->addColumn();
	gui->addLabel("> INTS");
    gui->addSeparator();
	gui->addParam("Int Radio (<=10)", &intValue1, 1, 3, 0)->setDisplayValue();		// !NEW! small int range will be displayed as radios
	gui->addParam("Int Radio (<=10)", &intValue2, 1, 10, 0)->setDisplayValue();		// !NEW! small int range will be displayed as radios
	gui->addParam("Int slider (>10)", &intValue3, 1, 11, 0)->setDisplayValue();		// !NEW! Display the value beside labels
	// stepped
    gui->addSeparator();
	ic = gui->addParam("Int Step 2", &intValue4, 0, 10, 0);
	ic->setDisplayValue();
	ic->setStep(2);														// !NEW! int step
	ic = gui->addParam("Int Step 2", &intValue5, 0, 18, 0);
	ic->setDisplayValue();
	ic->setStep(2);														// !NEW! int step
	ic = gui->addParam("Int Step 2", &intValue6, 0, 20, 0);
	ic->setDisplayValue();
	ic->setStep(2);														// !NEW! int step
	
	//
	// BYTE CONTROL
	gui->addColumn();
	gui->addLabel("> BYTES");
    gui->addSeparator();
	gui->addParam("Byte", &byteValue1, 0)->setDisplayValue();			// !NEW! ranges from 0-255
	btc = gui->addParam("Byte as char", &byteValue2, 0);				// !NEW! display as char
	btc->setDisplayValue();
	btc->displayChar = true;
	btc = gui->addParam("Byte as hex", &byteValue3, 0);					// !NEW! display as hex
	btc->setDisplayValue();
	btc->displayHex = true;
	// FLAGS
    gui->addSeparator();
	fc = gui->addParamFlag("Byte Flag", &flagValue, 8, 0x55);			// !NEW! Byte Flag
	fc->setDisplayValue();
	fc->displayHex = true;
	
	
	gui->load(CONFIG_FILE); //we load settings after specifying all the 
    //params because we need to know their name and type
	
	timer.start();
	prevTime = timer.getSeconds();
	
}
Example #7
0
void RogalarmApp::setup()
{
	mFullscreen = false;
	mUser		= false;
	mNoUserMessage    = false;
	setFullScreen(mFullscreen);
	mUserPos = 0;
	mDebug = false;	
	mKonnect = loadImage(loadResource("konnect-kinect.jpg") );
	
	try {
		mKinect = Kinect( Kinect::Device() );
		mKinectConected = true;
		
	} catch( ... ){
		mKinectConected = false;
	}
    
    
    mConfigPath = getResourcePath().c_str();
    mConfigPath += "settings.sgui.txt";
   
	
    
	mStopedTime = getElapsedSeconds();
	
	
	mTargetPosition = Vec3f::zero();
	
	mContourTexture = gl::Texture(getWindowWidth(), getWindowHeight());
	mDepthTexture = gl::Texture(getWindowWidth(), getWindowHeight());
	
	mGui = new SimpleGUI(this);
	mGui->lightColor = ColorA(1, 1, 0, 1);
	
	mGui->addLabel("CONTROLS");
	mGui->addParam("Depth Threshold", &mThreshold, 0, 255, 70);
	mGui->addParam("Min Contour Area", &mBlobMin, 10, 100, 30);
	mGui->addParam("Max Contour Area", &mBlobMax, 100, 500, 200);
	mGui->addSeparator();
	mGui->addParam("Reflection Top", &mReflectionTop, 0, 480, 0);
	mGui->addParam("Reflection Bottom", &mReflectionBottom, 0, 480, 0);
	mGui->addSeparator();
	mGui->addLabel("OPTIONS");
	mGui->addParam("Fullscreen (f)", &mFullscreen, false);
	mGui->addButton("Save Configuration")->registerClick(this, &RogalarmApp::openSaveConfigClick);
	mGui->addColumn(142, 7);
	mGui->addLabel("Contour Image");
	mGui->addParam("Contour Texture", &mContourTexture); 
	mGui->addLabel("Depth Image");
	mGui->addParam("Depth Texture", &mDepthTexture);
	
	mGui->load(mConfigPath);
	
	mHost = "10.0.1.137";
	mPort = 7110;
	mSender.setup(mHost, mPort);



}