Ejemplo n.º 1
0
void ScheinrieseApp::setup()
{
    // GUI
    mGui = new SimpleGUI(this);
    mGui->addColumn();
    mGui->addLabel("CONTROLS");
    mGui->addParam("Threshold", &mThreshold, 0, 255, 127);
    mGui->addParam("Blur", &mBlur, 1, 20, 1);
    mGui->addParam("Tilt", &mKinectTilt, -30, 30, 0);
    mGui->addColumn();
    mGui->addLabel("DEBUG VIEW");
    mGui->addParam("Show Debug", &mShowDebug, true);
//    mGui->addButton("Show Debug")->registerClick(this, &ScheinrieseApp::showDebug);

    mGui->load(getResourcePath(RES_SETTINGS));
    mGui->setEnabled(false);

    mBlur = 1;
    mThreshold = 127;

    mShowDebug = true;

    // KINECT
    hasKinect = false;
    console() << "### INFO: There are " << Kinect::getNumDevices() << " Kinects connected." << endl;
    if (Kinect::getNumDevices() >= 1) {
        mKinect = Kinect( Kinect::Device() );
        mKinect.setTilt(mKinectTilt);
        hasKinect = true;
    }
}
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;
    }
}
Ejemplo n.º 3
0
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());
    }
}
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("");
}