Пример #1
0
//--------------------------------------------------------------
void testApp::setup(){

//--------------------------------------------------------------
//Declaring all variables, initializing all textures, setting up video capture.
//Takes a while, eh?

    prefsFile.loadFile("params.xml");       //Get the parameters for image generation

    ofSetLogLevel(OF_LOG_VERBOSE);

    ofBackground(255,255,255);
    ofSetFrameRate(prefsFile.getValue("gl:glmaxframerate",30,0));
    if(prefsFile.getValue("gl:glusesmoothing",1,0) == 1){
        ofEnableSmoothing();
    }
    if(prefsFile.getValue("gl:glusearbtex",1,0) == 1){
        ofEnableArbTex();
    }
    ofEnableAlphaBlending();

    isPlayingIntro = true;

    showInstructions = false;       //Should we show the instructions pane?


    lRotate = 0;

	grayImg.allocate(640, 480);
    grayBG.allocate(640, 480);
    colorImg.allocate(640, 480);
    grayDiff.allocate(640, 480);
	videoGrabber.setVerbose(true);
	videoGrabber.initGrabber(640, 480, true);
	colorPreview.allocate(640, 480, GL_RGB);
	threshPreview.allocate(640, 480, GL_LUMINANCE);

	titles.allocate(772, 63, OF_IMAGE_COLOR_ALPHA);
	titles.loadImage("title.png");
	text1.allocate(800,800,OF_IMAGE_COLOR_ALPHA);
	text1.loadImage("img/text1.png");
	text2.allocate(912, 64, OF_IMAGE_COLOR_ALPHA);
	text2.loadImage("text2.png");
	gfxTitle.allocate(817, 458, OF_IMAGE_COLOR_ALPHA);
	gfxTitle.loadImage("img/title.png");

	debugFont.loadFont("arial.ttf", 8);
	introText.loadFont("arial.ttf", 24);
	//introMusic.loadSound("worksong.wav", true);
	introVid.loadMovie("zwcleantitle.mov");
	//vidText1.loadMovie("clip1.mov");

	p1Complete = false;
	p2Complete = false;
	p3Complete = false;
	p4Complete = false;

	currentPattern = 0;

    sDensity = 10;
	//Take care of this crap up front.

    int to = ofRandom(-10, 10);
    /*
    int td = sDensity;
    td += to;
    sDensity = ofClamp(td, 2, 50);
    */

    //Below is the initial load and setting of all relevant variables and reading from XML.
    //There are probably some things in this For loop that could be cut out of it...
    //As one can see, there is much optimization to be done.

    currentPattern = ofRandom(0,2);
    float wh;
    for(int i = 0; i < sDensity; i++){
        sNumShadows[i] = ofRandom(prefsFile.getValue("params:snshadowsmin", 0), prefsFile.getValue("params:snshadowsmax", 0));
        int a = prefsFile.getValue("params:stranslaterange", 0) / 2;
        sTranslateX[i] = ofRandom(a *= -1, a);
        sTranslateY[i] = ofRandom(a *= -1, a);
        int b = prefsFile.getValue("params:sdrawrange", 0);
        sDrawX[i] = ofRandom(b *= -1, b);
        sDrawY[i] = ofRandom(b *= -1, b);
        wh = ofRandom(prefsFile.getValue("params:ssizemodmin",0), prefsFile.getValue("params:ssizemodmax",0));
        sDrawWidth[i] = 640 * wh;
        sDrawHeight[i] = 480 * wh;
        sRotateAngle[i] = 360 / sNumShadows[i];
        sRandomFactor[i] = ofRandom(-100, 100);
        sThetaXMod[i] = ofRandom(prefsFile.getValue("params:sthetamodxmin", 0), prefsFile.getValue("params:sthetamodxmax",0));
        sThetaYMod[i] = ofRandom(prefsFile.getValue("params:sthetaymodmin",0), prefsFile.getValue("params:sthetaymodmax",0));
        mutAngle = ofRandom(prefsFile.getValue("params:mutanglemin",0),prefsFile.getValue("params:mutanglemax",0));
        innerRadius = ofRandom(prefsFile.getValue("params:innerradiusmin",0),prefsFile.getValue("params:innerradiusmax",0));
        outerRadius = ofRandom(prefsFile.getValue("params:outerradiusmin",0),prefsFile.getValue("params:outerradiusmax",0));
        nArms = ofRandom(prefsFile.getValue("params:snarmsmin",0),prefsFile.getValue("params:snarmsmax",0));
        nShadowsPerArm = ofRandom(prefsFile.getValue("params:snshadowsperarmmin",0),prefsFile.getValue("params:snshadowsperarmmax",0));
        nTunnelArms = ofRandom(5,15);
        nShadowsPerTunnelArm = ofRandom(20,30);
        nStars = ofRandom(5, 10);
        nRings = ofRandom(1, 10);
        nRingOffset = ofRandom(500, 700);
        sSeedColor = ofRandom(0,3);
        sSeedRGB = ofRandom(0, 255);
        sAlpha[i] = ofRandom(10, 200);
        if(sSeedColor == 0){
            sRed[i] = ofRandom(200, 255);
            sGreen[i] = ofRandom(0, 100);
            sBlue[i] = ofRandom(0, 100);
        }if(sSeedColor == 1){
            sRed[i] = ofRandom(0, 100);
            sGreen[i] = ofRandom(200, 255);
            sBlue[i] = ofRandom(0,100);
        }if(sSeedColor == 2){
            sRed[i] = ofRandom(0, 100);
            sGreen[i] = ofRandom(0, 100);
            sBlue[i] = ofRandom(200, 255);
        }
    }
    //::::::::::::::::::::::::::::::::::::::::

	nShadows = 50;
	theta = 230;
	nudgeX = 0;
	nudgeY = 0;

	for(int i = 0; i < 9; i++){
		randomVar[i] = 1;
	}

	thetamod1 = ofRandom(0,360);
	thetamod2 = ofRandom(0,360);
	thetamod3 = ofRandom(0,360);


//--------------------------------------------------------------

	bIntro = true;
	bIntro2 = false;
	if(prefsFile.getValue("init:usesongplayer",1,0) == 1){
        useSongPlayer = true;
	} else {
	    useSongPlayer = false;
	}
	showCamInput = false;
	sMusic = true;
	introFractal = false;
	fCount = 0;
	sCount = 0;
	zoomScale = 40000;

	shadow = new ofTexture*[nShadows];

	for(int i = 0; i < nShadows; i++){
		shadow[i] = new ofTexture;
		shadow[i]->allocate(640, 480, GL_RGBA);
	}

	nPoints = 10;
	radius = 260;
	threshold = 70;
	cY = ofGetScreenHeight() / 2;
	cX = ofGetScreenWidth() / 2;
}
Пример #2
0
//--------------------------------------------------------------
void ofApp::setup(){
//-------------------------
    
    int num = 1500;
    p.assign(num, demoParticle());
    currentMode = PARTICLE_MODE_NEAREST_POINTS;
    
    resetParticles();
    
    ofBackground(100, 100, 100);
    
    vidGrabber.setVerbose(true);
    vidGrabber.setup(vidX,vidY);  // setup live video grabbing
    colorImg.allocate(vidX,vidY);  // color image display
    grayImage.allocate(vidX,vidY); // grayscale display
    grayBg.allocate(vidX,vidY);	   // contour image
    grayDiff.allocate(vidX,vidY);  // b/w differencing image
    bLearnBakground = true;
    threshold = 80;
    
    ofSetVerticalSync(true);
    bSendSerialMessage = false;
    ofSetLogLevel(OF_LOG_VERBOSE);
    
    int baud = 9600;
    serial.setup("/dev/cu.usbmodem1411", baud);
    
    nTimesRead = 0;
    nBytesRead = 0;
    readTime = 0;
    
    memset(bytesReadString, 0, 4);
    
    font.load("NADISN__.TTF", 12);
    font2.load("NADISN__.TTF", 24);
    _i = ofClamp(i, 0, 14);
    
    mov1.load("hel-0world.mp4");
    mov1.setLoopState(OF_LOOP_NORMAL);
    mov1.play();
    
    music1.load("1.wav");
    music2.load("2.wav");
    music3.load("3.wav");
    music4.load("4.wav");
    music5.load("5.wav");
    music6.load("6.wav");
    music7.load("7.wav");
    music8.load("8.wav");
    music9.load("9.wav");
    music10.load("10.wav");
    music11.load("11.wav");
    music12.load("12.wav");
    music13.load("11.wav");
    music14.load("12.wav");
    music15.load("13.wav");
    
    music1.play();
    music2.play();
    music3.play();
    music4.play();
    music5.play();
    music6.play();
    music7.play();
    music8.play();
    music9.play();
    music10.play();
    music11.play();
    music12.play();
    music13.play();
    music14.play();
    music15.play();
    
    music1.setPaused(true);
    music2.setPaused(true);
    music3.setPaused(true);
    music4.setPaused(true);
    music5.setPaused(true);
    music6.setPaused(true);
    music7.setPaused(true);
    music8.setPaused(true);
    music9.setPaused(true);
    music10.setPaused(true);
    music11.setPaused(true);
    music12.setPaused(true);
    music13.setPaused(true);
    music14.setPaused(true);
    music15.setPaused(true);
    
    img1.load("01.png");
    img2.load("02.png");
    img3.load("03.png");
    img4.load("04.png");
    img5.load("05.png");
    img6.load("06.png");
    img7.load("07.png");
    img8.load("08.png");
    img9.load("09.png");
    img10.load("10.png");
    img11.load("11.png");
    img12.load("12.png");
    img13.load("13.png");
    
}
Пример #3
0
//--------------------------------------------------------------
void gamuzaMain::setup(){

	flagSystemLoaded	= false; // first line of gamuza setup

	//////////////////////////////////////////////
	// load settings from xml
	loadGamuzaSettings();
	// automation
    isFullscreen = false;
	if(autoPilot){
		gamuzaFullscreen();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// init general openframeworks settings
    ofSetEscapeQuitsApp(false);
	ofSetFrameRate(200);
	ofEnableSmoothing();
	ofSetLogLevel(OF_LOG_VERBOSE);
	//////////////////////////////////////////////

    //////////////////////////////////////////////
	// OSC data sending @ host_number(IP),host_port
    gamuzaSetup.lock();
    setupOSC();
    gamuzaSetup.unlock();
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// AUDIO
	if(audioActivated){
		gamuzaSetup.lock();
		setupAudio();
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

    //////////////////////////////////////////////
	// MIDI
    gamuzaSetup.lock();
    setupMidi();
    gamuzaSetup.unlock();
    //////////////////////////////////////////////

	//////////////////////////////////////////////
	// OPENNI
	if(openniActivated){
		gamuzaSetup.lock();
		sensorKinect.setupDevice(workingW,workingH,useKinectInfrared,sensorKinectLedState);
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// FBO second screen output texture
	gamuzaSetup.lock();
	setupFBO();
	gamuzaSetup.unlock();
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// ARDUINO
	if(arduinoActivated){
		gamuzaSetup.lock();
		setupArduino();
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// GUI
	// include setup of webcams & audio inputs
	gamuzaSetup.lock();
    setupSettingPanel();
	setupGui();
	gamuzaSetup.unlock();
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// SYSTEM
	currentSavedFrame   = 0;
    gaFrameCounter      = 0;
    //////////////////////////////////////////////

	//////////////////////////////////////////////
	// set log level to error only
	ofSetLogLevel(OF_LOG_ERROR);
    sendPrivateMessage(GAMUZA_CONSOLE_LOG, " ");
	//////////////////////////////////////////////

}
Пример #4
0
//--------------------------------------------------------------
void testApp::setup(){	 

	printf("testApp::setup()\n");

	shutdown_started = false;
	
#ifndef NO_WINDOW
	ofSetVerticalSync(true);
	ofBackground(20,20,20);	
	ofEnableAlphaBlending();
	ofSetFrameRate( 60 );
#endif
	
#ifdef NO_WINDOW
	ofSetDataPathRoot( "data/" );
	ofSetFrameRate( 60 ); 
#endif
	
	ofSetLogLevel( OF_LOG_NOTICE );
	
	serial.enumerateDevices();
#ifdef TARGET_LINUX
	static const char* SERIAL_PORT = "/dev/ttyUSB0";
#elif defined TARGET_OSX
	static const char* SERIAL_PORT = "/dev/tty.usbserial-FTT8R2AA";
	//static const char* SERIAL_PORT = "/dev/tty.usbserial-0000103D";
	//static const char* SERIAL_PORT = "/dev/tty.usbserial-A4000R0L";
	//static const char* SERIAL_PORT	 = "/dev/tty.usbserial-FTTEIQQY";
#endif
	static const int BAUDRATE = 19200;
	if ( serial.setup(SERIAL_PORT, BAUDRATE ) )
		buffered_serial = new BufferedSerial();
	else
	{
		printf("couldn't open serial %s, making dummy\n", SERIAL_PORT );
		buffered_serial = new BufferedSerialDummy();
	}
	buffered_serial->setup( &serial, BAUDRATE );

	// osc
	static const char* OSC_HOST = "localhost";
	static const int OSC_PORT = 10001;
	osc.setup( OSC_HOST, OSC_PORT );
	
	
	// load settings
	ofxXmlSettings data;
	if ( data.loadFile( "settings.xml" ) )
		lights.setup( buffered_serial, data );
	else
	{
		ofLog( OF_LOG_ERROR, "couldn't load data/settings.xml");
		lights.setup( buffered_serial );
	}
	
	ontime_ms = data.getValue("ontime_ms", 0 );
	printf("got ontime_ms: %i\n", ontime_ms );
	
	
	data.popTag();
	

	AnimationFactory::useLights( &lights );
    
    anim_switcher.addAnim( AnimSeq::NAME );

	anim_switcher.addAnim( AnimGazebo::NAME );
	anim_switcher.addAnim( AnimKapelica::NAME );
	anim_switcher.addAnim( AnimStateMachine::NAME );
	anim_switcher.addAnim( AnimSweep::NAME );
	anim_switcher.addAnim( AnimDelaunay::NAME );
	anim_switcher.addAnim( AnimPositionCalibrate::NAME );
	anim_switcher.addAnim( AnimSeq::NAME );
	anim_switcher.addAnim( AnimSeqSine::NAME );

	current_anim = anim_switcher.goToAnim( AnimSeq::NAME );
	
#ifdef DO_PD
	printf("starting pd...\n");
	
	pd.setup( "" );
	//pd.addOpenFile( "pd-test.pd" );
	pd.addOpenFile( "pdstuff/_main.pd" );
	pd.start();

	ofSoundStreamSetup(2, 0, this, 44100, 256, 4 );
#endif
	
	ofSoundStreamSetup(2, 0, this, 44100, 256, 12 );
	printf("testApp::setup() finished\n");
	
}
Пример #5
0
//--------------------------------------------------------------
void testApp::setup() {
	
	ofSetVerticalSync(true);
	ofSetLogLevel(OF_LOG_NOTICE);
    
    ofEnableAlphaBlending();

	ofBackgroundHex(0x333333);
    bgImage.loadImage("bg.png");
   

    
    loadColors();
    sortByCategory = false;
//    bool mousePressed = false;
    
    ofTrueTypeFont::setGlobalDpi(72);

    myFont.loadFont("GothamHTF-Bold.otf", 29, true, true, true);
    myFontMed.loadFont("GothamHTF-Bold.otf", 18, true, true, true);
    myFontSmall.loadFont("GothamHTF-Bold.otf", 14, true, true, true);

    myFont.setLineHeight(28.0f);
    myFontSmall.setLineHeight(18.0f);
	myFontMed.setLetterSpacing(.95);

    
  //  myFont.loadFont("GothamHTF-Bold.otf", 32, true, true, true);
    
    typeString = "hiyoooo";
    
    // load NYTimes data
    dataString = fileLoader.loadFromUrl("http://localhost/algo/algo-dummy_data.txt");

    result = ofSplitString(dataString, "!");

    for(int i = 0; i< result.size(); i++){
        if(tempResult.size() > 0){
            tempResult.clear();
        }
        tempResult = ofSplitString(result[i], "#");
        nestedResults.push_back(tempResult);
    }
    

//    for(int i=0; i< nestedResults[0].size(); i++){
//        cout << nestedResults[0][i] << "###\n";        
//    }

    

    
	numEmailsStart = 80;
    numCategoriesStart = 20;
    numCategories = 20;
    
    radius = 17;
    
    unitRadius = 110;

    xShift = 0;
    yShift = 20;
    
    saved = 0;
    trash = 0;
    
	box2d.init();
	box2d.setFPS(30.0);
    box2d.registerGrabbing();
    box2d.setGravity(0,0);
    box2d.createBounds(0,0,ofGetWidth()+1000,ofGetHeight());
		

    
    for(int i=0; i<numCategoriesStart; i++) {
   //     resetAttractionPoints(numCategories);
        catHasArticles[i] = false;
    }
   
    // add email/circles to world
	for (int i=0; i < numEmailsStart; i++) {
       if(nestedResults[i].size() > 0) {    
            if(indexForCategory(nestedResults[i][CATEGORY]) > -1){
              //  addEmail(i%numCategories);
                addEmail(indexForCategory(nestedResults[i][CATEGORY]), i);
                
                // keeping track of which articles actually have articles in them
                catHasArticles[indexForCategory(nestedResults[i][CATEGORY])] = true;
            }
        }
    }
    
    for (int i=0; i<emails.size(); i++) {
        emails[i].setInitialConditions();
    }
    
    //now keep track of reverse (what index is for current category)
    for(int i=0; i<numCategoriesStart; i++) {
        if(catHasArticles[i] == true){
            categoriesWithArticles.push_back(i);
            currentCategoryKeys[i] = categoriesWithArticles.size() -1;
        }
        else {
            currentCategoryKeys[i] = -1;
        }
    }
    
    
    for(int i=0; i<numCategoriesStart; i++) {
        cout << currentCategoryKeys[i] << "\n";
    }

    numCategories = categoriesWithArticles.size();
    
    for (int i = 0; i < numCategories ; i++) {
         resetAttractionPoints(numCategories);
    }
    ;
}
Пример #6
0
//--------------------------------------------------------------
void testApp::setup() {
    
    Tweenzor::init( ) ; 
    ofSetLogLevel(OF_LOG_WARNING);

        bDrawOpenNI = false;
     
//#ifndef USE_ONI_MOVIE
    openNIDevice.setup();
    openNIDevice.addImageGenerator();
    openNIDevice.addDepthGenerator();
    openNIDevice.setRegister(true);
    openNIDevice.setMirror(false);
    openNIDevice.addUserGenerator();
    openNIDevice.setMaxNumUsers(4);
    openNIDevice.start();
    
    // set properties for all user masks and point clouds
    //openNIDevice.setUseMaskPixelsAllUsers(true); // if you just want pixels, use this set to true
    openNIDevice.setUseMaskTextureAllUsers(true); // this turns on mask pixels internally AND creates mask textures efficiently
    openNIDevice.setUsePointCloudsAllUsers(false);
   // openNIDevice.setPointCloudDrawSizeAllUsers(2); // size of each 'point' in the point cloud
   // openNIDevice.setPointCloudResolutionAllUsers(2); // resolution of the mesh created for the point cloud eg., this will use every second depth pixel
    
    // you can alternatively create a 'base' user class
//    ofxOpenNIUser user;
//    user.setUseMaskTexture(true);
//    user.setUsePointCloud(true);
//    user.setPointCloudDrawSize(2);
//    user.setPointCloudResolution(2);
//    openNIDevice.setBaseUserClass(user);
//#endif

    /*
    openNIPlayer.setup();
    openNIPlayer.addImageGenerator();
    openNIPlayer.addDepthGenerator();
    openNIPlayer.setRegister(true);
    openNIPlayer.setMirror(false);
    openNIPlayer.addUserGenerator();
    openNIPlayer.setMaxNumUsers(2);
	openNIPlayer.start();
    
    openNIPlayer.setUseMaskTextureAllUsers(true); // this turns on mask pixels internally AND creates mask textures efficiently
    openNIPlayer.setUsePointCloudsAllUsers(false);*/
   // openNIPlayer.setPointCloudDrawSizeAllUsers(2); // size of each 'point' in the point cloud
   // openNIPlayer.setPointCloudResolutionAllUsers(2); // resolution of the mesh created for the point cloud eg., this will use every second depth pixel
    
    colorPool.push_back( ofColor( 242, 56 , 90 ) ) ;
    colorPool.push_back( ofColor( 245, 165 , 3 ) ) ;
    colorPool.push_back( ofColor( 233, 241 , 223 ) ) ;
    colorPool.push_back( ofColor( 74, 217 , 217 ) ) ;
    colorPool.push_back( ofColor( 54, 177 , 191 ) ) ;
    verdana.loadFont(ofToDataPath("verdana.ttf"), 24);
    
    roiArea = ofRectangle( ofRandomWidth() , ofRandomHeight() , ofRandomWidth() , ofRandomHeight() ) ;
    bUseRoi = false ;
    bFullscreen = false ;
    
    bCalibrateSpace = true ;
       
    loadRoiCalibration() ;
    
    init_ofxUI ( ) ;
    
    for ( int i = 0 ; i < 15 ; i++ )
    {
        JointRoute jr ;
        jointRoutes.push_back( jr ) ;
        skeleton.push_back ( ofPoint() ) ; 
    }
    
    jointRoutes[0].addIndex(1) ;
    jointRoutes[0].addIndex(9) ;
    jointRoutes[0].addIndex(12) ;
    
    jointRoutes[1].addIndex(3) ;
    jointRoutes[1].addIndex(6) ;
    jointRoutes[1].addIndex(2) ;
    jointRoutes[2].addIndex(-1) ;
    
    jointRoutes[3].addIndex(4) ;
    jointRoutes[3].addIndex(4) ;
    jointRoutes[4].addIndex(5) ;
    jointRoutes[4].addIndex(5) ;
    jointRoutes[5].addIndex(-1) ;
    
    jointRoutes[6].addIndex(7) ;
    jointRoutes[6].addIndex(7) ;
    jointRoutes[7].addIndex(8) ;
    jointRoutes[7].addIndex(8) ;
    jointRoutes[8].addIndex(-1) ;
    jointRoutes[9].addIndex(10) ;
    jointRoutes[10].addIndex(11) ;
    jointRoutes[11].addIndex(-1) ;
    
    jointRoutes[12].addIndex(13) ;
    jointRoutes[13].addIndex(14) ;
    jointRoutes[14].addIndex(-1) ;

    
    lastSpawn = 0 ;
    spawnDelay = 1.5f ;
    bDepthRegistration = false ;
      
    fbo.allocate( ofGetWidth() , ofGetHeight() , GL_RGBA ) ;
    fbo.begin() ;
        ofClear( 1 , 1 , 1, 0 ) ; 
    fbo.end() ;

    bSkeletonActive = false ;

}
Пример #7
0
//--------------------------------------------------------------
void ofApp::setup(){
	ofSetWindowTitle("Story Teller");
	//Software2552::SoundIn::setup();// move to timeline or scene
	//Software2552::SoundOut::setup();// move to timeline or scene

	ofSetLogLevel(OF_LOG_NOTICE);//OF_LOG_VERBOSE
	timeline.setup();
	timeline.readScript("json3.json");
	timeline.start();
	//paragraphs.build(ofGetWidth());
	
	//ofSetFullscreen(true);
	//ofSetFrameRate(60);
	//ofBackgroundHex(0x00000);
	//ofSetLogLevel(OF_LOG_NOTICE);//ofSetLogLevel(OF_LOG_VERBOSE);
	
	// we add this listener before setting up so the initial circle resolution is correct
#if 0
	circleResolution.addListener(this, &ofApp::circleResolutionChanged);
	ringButton.addListener(this, &ofApp::ringButtonPressed);

	gui.setup(); // most of the time you don't need a name
	gui.add(filled.setup("fill", true));
	gui.add(radius.setup("radius", 140, 10, 300));
	gui.add(center.setup("center", ofVec2f(ofGetWidth()*.5, ofGetHeight()*.5), ofVec2f(0, 0), ofVec2f(ofGetWidth(), ofGetHeight())));
	gui.add(color.setup("color", ofColor(100, 100, 140), ofColor(0, 0), ofColor(255, 255)));
	gui.add(circleResolution.setup("circle res", 5, 3, 90));
	gui.add(twoCircles.setup("two circles"));
	gui.add(ringButton.setup("ring"));
	gui.add(screenSize.setup("screen size", ofToString(ofGetWidth()) + "x" + ofToString(ofGetHeight())));

	bHide = false;

	ring.load("ring.wav");
#endif // 0

	years = 0;
	return;
	// show images, then wash them away

#if 0
	images.push_back(ofImage("C:\\Users\\mark\\Pictures\\maps\\Res37.jpe"));
	images.push_back(ofImage("C:\\Users\\mark\\Pictures\\maps\\Res37-2.jpe"));
	images.push_back(ofImage("C:\\Users\\mark\\Pictures\\maps\\Res37-2.jpe"));
	franklinBook14.load("frabk.ttf", 14, true, true, true);
	franklinBook14.setLineHeight(18.0f);
	franklinBook14.setLetterSpacing(1.037);
	ofDisableDepthTest();
	return;
	backgroundImage.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR);
	backgroundImage.loadImage("C:\\Users\\mark\\Documents\\iclone\\images\\robot.jpg");
	// read the directory for the images
	// we know that they are named in seq
	ofDirectory dir;

	int nFiles = dir.listDir("C:\\Users\\mark\\Documents\\iclone\\images");
	if (nFiles) {

		for (int i = 0; i < dir.size(); i++) {

			// add the image to the vector
			string filePath = dir.getPath(i);
			images.push_back(ofImage());
			images.back().load(filePath);

		}

	}
	else ofLog(OF_LOG_WARNING) << "Could not find folder";

	// this toggle will tell the sequence
		// be be indepent of the app fps
	bFrameIndependent = true;

	// this will readJsonValue the speed to play 
	// the animation back we readJsonValue the
	// default to 24fps
	sequenceFPS = 24;

	// readJsonValue the app fps 
	appFPS = 18;
	ofSetFrameRate(appFPS);

	myPlayer.loadMovie("C:\\Users\\mark\\Documents\\iclone\\background2.mp4");
	myPlayer.setLoopState(OF_LOOP_NORMAL);
	myPlayer.play();

	robot.loadMovie("C:\\Users\\mark\\Documents\\iclone\\images\\robot2.mp4");
	robot.setLoopState(OF_LOOP_NORMAL);
	robot.play();


	pathLines.setMode(OF_PRIMITIVE_LINE_STRIP);
	ofDisableArbTex(); // we need GL_TEXTURE_2D for our models coords.
	ofEnableDepthTest();
	light.enable();
	cam.setPosition(0, 0, 100);

	headTrackedCamera.setNearClip(0.01f);
	headTrackedCamera.setFarClip(1000.0f);

	//defining the real world coordinates of the window which is being headtracked is important for visual accuracy
	windowWidth = 0.3f;
	windowHeight = 0.2f;

	windowTopLeft = ofVec3f(-windowWidth / 2.0f,
		+windowHeight / 2.0f,
		0.0f);
	windowBottomLeft = ofVec3f(-windowWidth / 2.0f,
		-windowHeight / 2.0f,
		0.0f);
	windowBottomRight = ofVec3f(+windowWidth / 2.0f,
		-windowHeight / 2.0f,
		0.0f);

	//we use this constant since we're using a really hacky headtracking in this example
	//if you use something that can properly locate the head in 3d (like a kinect), you don't need this fudge factor
	viewerDistance = 0.4f;


	//From2552Software::Sound sound;
	//sound.test();

	myKinect.open();
	//audio.setup(&myKinect);
	//audio.setup(&myKinect);
	//audio.setup(&myKinect);

	//faces.setup(&myKinect);
	bodies.useFaces();
	bodies.setup(&myKinect);

	//ofSetWindowShape(640 * 2, 480 * 2);
	ofDisableDepthTest(); // draws in order vs z order

#endif // 0

}
Пример #8
0
//--------------------------------------------------------------
void testApp::setup(){
	
	ofSetVerticalSync(true);
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofSetFrameRate(60);
	
	
	// XML LOAD ------------------------------------------------*
	
	XML.loadFile("app_settings.xml");
	
	// SET NUMBER OF MODULES HERE ------------------------------*
	
	XML.pushTag("all", 0);
	numMod = XML.getValue("numMod", 1, 0); // -------------------------------------------***
	filesPath = XML.getValue("filesPath", "", 0);
	bExhibitionMode = XML.getValue("bExhibitionMode", false, 0);
	XML.popTag();
	
	// SET OSC HERE --------------------------------------------*
	
	XML.pushTag("all", 0);
	oscHost = XML.getValue("oscHost", "localhost", 0); // -------------------------------***
	oscPort = XML.getValue("oscPort", 1234, 0); // ---------------------------------------***
	XML.popTag();
	
	oscSender.setup(oscHost, oscPort);
	
	// ---------------------------------------------------------*
	
	// DRAWING VARS --------------------------------------------*
	
	camWidth 		= 640;
	camHeight 		= 480;
	
	dispWidth		= 1280;
	dispHeight		= 720;
	
	drawWidth		= 640;
	drawHeight		= 360;
	drawX			= 500;
	drawY			= 115;
	
	screenWidth		= (numMod + 1) * dispWidth;
	screenHeight	= dispHeight;
	
	ofSetWindowShape(screenWidth, screenHeight);
	
	
	// ---------------------------------------------------------*
	
	// OBJECT ARRAYS -------------------------------------------*
	
	modules = new margModule[numMod];
	textures = new ofTexture[numMod];	
	
	// SETUP VARS ----------------------------------------------*
	
	curMod = -1;
	
	modes[0] = "SOURCE";
	modes[1] = "LENSCORRECTED_SOURCE";
	modes[2] = "WARPED_SOURCE";
	modes[3] = "THRESHOLD_SOURCE";
	modes[4] = "TRAIL_MAP";
	modes[5] = "FINAL_IMAGE";
	modes[6] = "BYPASS_VIDEO";
	
	interactModes[0] = "NORMAL_TRAIL";
	interactModes[1] = "NO_FADE_TRAIL";
	interactModes[2] = "BYPASS_TRAIL";
	
	quads[0] = "DISP_QUAD";
	quads[1] = "CAPT_QUAD";
	
	blobsToDraw[0] = "ORIGINAL_BLOBS";
	blobsToDraw[1] = "CORRECTED_BLOBS";
	blobsToDraw[2] = "INTERPOLATED_BLOBS";

	
	// MODULE INITIALIZATION -----------------------------------*
	
	for (int i = 0; i < numMod; i++) {
		XML.pushTag("module", i);
		
		int capt = XML.getValue("captDev", -1, 0);
		string moviePath = XML.getValue("moviePath", filesPath + "movies/", 0);
		
		XML.popTag();
		
		modules[i].init(camWidth, camHeight, dispWidth, dispHeight, capt, i, filesPath, moviePath, bExhibitionMode);
		modules[i].setSharedVarsAddresses(&minBlob, &maxBlob, &numBlob,
										  &maxDist, &maxAreaDiff, &maxUnfitness,
										  &blobDefScaleFactor, &blobCondScaleConst, &blobCondScaleMax,
										  &exposureConst, &fadeConst, &blurLevel,
										  &displayMode, &bDynInteractMode,
										  &bDrawBlobs, &whichBlobs,
										  &bAdjQuad, &whichQuad);
		textures[i].allocate(dispWidth, dispHeight, GL_RGB);
	}
	
	oscMessage.setAddress("/sound/play");
	
	if (checkEveryModNeedPlay()) {
		for (int i = 0; i < numMod; i++) {
			modules[i].playVideos();
		}
		oscSender.sendMessage(oscMessage);
	}
	
	// INTERFACE SETUP ----------------------------------------*
	
	gui.addComboBox("Display Mode", displayMode, 7, modes);
	gui.addToggle("No warp control", bDrawUndistorted);
	gui.addToggle("Dynamic Interact Mode", bDynInteractMode);
	gui.addToggle("Control Display", bControlDisplay);
	gui.addToggle("External Display", bExtDisplay);
	gui.addToggle("Run Thread", bRunThread);
	gui.addToggle("Stop Thread", bStopThread);
	gui.addToggle("Update Settings", bUpdateSettings);
	gui.addToggle("Draw White", bDrawWhite);
	
	gui.currentPage().setXMLPath(filesPath);
	
	for (int i = 0; i < numMod; i++) {
		gui.addSlider("Module " + ofToString(i) + " FPS", (float&)modules[i].moduleFPS, 0, 1);
	}
	
	for (int i = 0 ; i < numMod; i++) {
		gui.addPage("Capture " + ofToString(i));
		gui.addToggle("Video Settings", opVidSet);
		gui.addComboBox("Interaction Mode", modules[i].interactMode, 3, interactModes);
		gui.addToggle("Adj Quad", bAdjQuad);
		gui.addComboBox("Which Quad to Adj", whichQuad, 2, quads);
		gui.addToggle("Clear Quad", clearQuad);
		gui.addSlider("Threshold Min", modules[i].blobFindThreshMin, 0, 255);
		gui.addSlider("Threshold Max", modules[i].blobFindThreshMax, 0, 255);
		gui.addTitle("Lens Correction");
		gui.addSlider("RadialDistX", (float&)modules[i].correctRdX, (float)-1.000, (float)1.000);
		gui.addSlider("RadialDistY", (float&)modules[i].correctRdY, (float)-1.000, (float)1.000);
		gui.addSlider("TangentDistX", (float&)modules[i].correctTgX, (float)-1.000, (float)1.000);
		gui.addSlider("TangentDistY", (float&)modules[i].correctTgY, (float)-1.000, (float)1.000);
		gui.addSlider("FocalX", (float&)modules[i].correctFX, (float)0.000, (float)camWidth);
		gui.addSlider("FocalY", (float&)modules[i].correctFY, (float)0.000, (float)camHeight);
		gui.addSlider("CenterX", (float&)modules[i].correctCX, (float)0.000, (float)camWidth);
		gui.addSlider("CenterY", (float&)modules[i].correctCY, (float)0.000, (float)camHeight);
		gui.currentPage().setXMLPath(filesPath);
	}
	
	gui.addPage("Blob Detection");
	gui.addSlider("Blob Min Area", minBlob, 0, 307200);
	gui.addSlider("Blob Max Area", maxBlob, 0, 307200);
	gui.addSlider("Blob Max Number", numBlob, 0, 20);
	
	gui.addTitle("Blob Tracking");
	gui.addSlider("Max Area Diff", maxAreaDiff, 0, 100);
	gui.addSlider("Max Dist", maxDist, 0, 150);
	
	gui.addTitle("Blob Scaling");
	gui.addSlider("Def. Scale Factor", blobDefScaleFactor, 0.5, 4.0);
	gui.addSlider("Cond. Scale Const.", blobCondScaleConst, 0.0, 3.0);
	gui.addSlider("Cond. Scale Max.", blobCondScaleMax, 1.0, 6.0);
	
	gui.addTitle("Blob Drawing");
	gui.addToggle("Draw Blobs", bDrawBlobs);
	gui.addComboBox("Which Blobs to Draw", whichBlobs, 3, blobsToDraw);
	
	gui.addTitle("Trail");
	gui.addSlider("Exp Const", exposureConst, 0, 15);
	gui.addSlider("Fade Const", fadeConst, 0, 1.0);
	gui.addSlider("Blur Level", blurLevel, 0, 10);
	
	gui.currentPage().setXMLPath(filesPath);
	
	gui.loadFromXML();
	
	gui.show();
	gui.setAutoSave(false);
	
	// ---------------------------------------------------------*
	
	for(int i = 0; i < numMod; i++) {
		modules[i].updateSettings();
	}

}
//--------------------------------------------------------
void captureApp::setup(){
	ofSetLogLevel(OF_LOG_NOTICE);
	serial.enumerateDevices();
	
	ofxXmlSettings serialSetup;
	serialSetup.loadFile("serialSettings.xml");
	string serialPort = serialSetup.getValue("serialPort", "");
	serial.setup(serialPort, 9600);		// < this should be set
	// to whatever com port
	// your serial device is 
	// connected to.  
	// (ie, COM4 on a pc, dev/tty.... on a mac)
	// arduino users check in arduino app....
	serial.flush();
	
	state			= CAP_STATE_WAITING;
	debugState		= CAP_NORMAL;
	camState		= CAMERA_CLOSED;
	prevCamState	= CAMERA_CLOSED;
	
	preCamMode				= 0;
	cameraFrameNum			= 0;
	sdk						= NULL;
	settings				= NULL;
	timeToEndCapture		= 0.0;
	bNeedsToLeaveFrame		= false;
	bOscSetup				= false;
	fadeInStartTime			= 0.0;
	spotLightAlpha			= 1.0;
	bDoThreadedRSync		= false;
	bDoThreadedFrameSave	= false;
	
	camera3D.disableMouseEvents();
				
	if( !ofxFileHelper::doesFileExist(CAPTURE_MAIN_FOLDER) ){
		printf("making folder %s\n", CAPTURE_MAIN_FOLDER.c_str());
		ofxFileHelper::makeDirectory(CAPTURE_MAIN_FOLDER);
	}
	
	if( !ofxFileHelper::doesFileExist(EXPORT_FOLDER) ){
		printf("making folder %s\n", EXPORT_FOLDER.c_str());	
		ofxFileHelper::makeDirectory(EXPORT_FOLDER);
		if( !ofxFileHelper::doesFileExist(DECODE_FOLDER) ){
			ofxFileHelper::makeDirectory(DECODE_FOLDER);
		}		
	}
	
	ofxXmlSettings xml;
	xml.loadFile("locationSettings.xml");
	currentCity			= xml.getValue("city_name", "NYC");
	transformSpaces(currentCity); //remove space and add underscores
	currentDecodePath		= DECODE_FOLDER;
	currentCaptureFolder    = string(CAPTURE_MAIN_FOLDER) + FRAME_CAPTURE_FOLDER;
	currentTimestamp		= (ofxTimeStamp()).getUnixTimeAsString();
	
	// setup panel
	panel.setup("control", 0, 0, 300, 768);

	panel.setBackgroundColor(simpleColor(10, 10, 10, 0));
		
	//panel.loadFont("resources/myFont.ttf", 9);
	panel.addPanel("app/capture settings", 1);
	panel.addPanel("app settings", 1);
	panel.addPanel("face trigger settings", 1);
	panel.addPanel("pattern settings", 1);
	panel.addPanel("misc settings", 1);
	
	panel.setWhichPanel("app/capture settings");

	panel.addToggle("use face trigger", "B_FACE_TRIGGER", false);
	
	vector <string> camModes;
	camModes.push_back("camera off");
	camModes.push_back("camera qt");
	camModes.push_back("camera dc1394");
	
	panel.addMultiToggle("camera mode", "camMode", 0, camModes);
	
	panel.addToggle("camera settings", "cameraSettings", false);
	
	panel.addToggle("overide light", "bOverideLight", true);
	panel.addToggle("show red clipping", "SHOW_RED", true);

	panel.addToggle("fullscreen", "fullscreen", false);
	
	panel.addToggle("spot light image", "bSpotLight", true);
	panel.addSlider("spotlight %", "spotLightBrightness", 1.0, 0.0, 1.0, false);
	
	panel.addToggle("frame by frame", "frameByFrame", false);
	panel.addToggle("large video", "largeVideo", false);

	panel.addSlider("min brightness", "minBrightness", 0, 0, 255, true);
	panel.addSlider("max brightness", "maxBrightness", 255, 0, 255, true);	
	panel.addSlider("3 phase - wavelength", "wavelength", 64, 8, 512, true);
	panel.addToggle("use projector lut", "projectorLut", false);
		
	panel.setWhichPanel("app settings");
	
	panel.addSlider("fade in time", "fadeInTime", 2.0, 0.0, 5.0, false);
	
	vector<string> postCapModes;
	postCapModes.push_back("save frames");
	postCapModes.push_back("decode and frames");
	postCapModes.push_back("decode, export and frames");
	postCapModes.push_back("all above + notify");
	panel.addMultiToggle("post capture:", "postCapture", 2, postCapModes);
	
	panel.addToggle("notify with osc", "use_osc", false);
	
	panel.addSlider("decode skip frames", "decodeSkipFrame", 2, 0, 5, true);
	
	panel.addSlider("capture time f", "CAPTURE_TIME_F", 4.0, 2.0, 15.0, false);
	
	panel.setWhichPanel("pattern settings");
	
	panel.addSlider("pattern rate", "patternRate", 1, 1, 6, true);
	panel.addSlider("camera rate", "cameraRate", 1, 1, 6, true);
	panel.addSlider("camera offset", "cameraOffset", 0, 0, 5, true);
	
	panel.addToggle("reverse", "reverse", false);
	
	vector<string> orientations;
	orientations.push_back("vertical");
	orientations.push_back("horizonal");
	panel.addMultiToggle("orientation", "orientation", 0, orientations);
	
	
	panel.setWhichPanel("face trigger settings");
	panel.addSlider("face trigger fps", "FACE_FPS", 10, 3, 30, false);
	panel.addSlider("face detected time", "FACE_DETECT_TIME", 2.0, 0.1, 10.0, false);
	panel.addSlider("face forget time", "FACE_FORGET_TIME", 2.0, 0.1, 10.0, false);
	
	guiStatVarPointer varPtr;
	varPtr.setup("num faces", &face.numFaces, GUI_VAR_INT, true);
	panel.addChartPlotter("num faces", varPtr, 240, 60, 240, -1, 3);
	panel.addChartPlotter("face confidence", guiStatVarPointer("confidence", &face.confidence, GUI_VAR_FLOAT, true, 2), 240, 70, 240, -0.2, 1.2);
	
	panel.addDrawableRect("state", &face, 240, 40);
	
	panel.addSlider("confidence add amnt", "confidence_add", 0.1, 0.05, 1.0, false);
	panel.addSlider("confidence fade amnt", "confidence_fade", 0.95, 0.8, 0.995, false);
	panel.addSlider("confidence gate start val", "confidence_gate_start", 0.65, 0.15, 1.0, false);
	panel.addSlider("confidence gate stop val", "confidence_gate_stop", 0.4, 0.0, 1.0, false);
	
	panel.setWhichPanel("misc settings");
	
	panel.addToggle("brightness setting", "brightnessSetting", false);
	panel.addSlider("check brigheness", "checkBrightness", 0, 0, 255, true);
	panel.addToggle("delete after transfer", "bDeleteAfterSend", false);
	panel.addToggle("restart at 3.00am", "bRestart", false);
	panel.addSlider("restart hour", "restartHour", 3, 1, 23, true);
	panel.addSlider("restart minute", "restartMinute", 0, 0, 59, true);
	
	panel.loadSettings("controlCapture.xml");
	
	if( panel.getValueB("use_osc") ){
		setupOsc();
	}
	
	//overides 
	//panel.setValueI("camMode", 0);
	panel.setValueI("fullscreen", 1);
	panel.setValueI("cameraSettings", 0);
	panel.setValueI("frameByFrame", 0);
	panel.setValueI("largeVideo", 0);
	panel.setValueI("brightnessSetting",0);
	panel.setValueI("bOverideLight",0);
	panel.setValueI("bSpotLight", 1);
	
	cameraWidth  = 640;
	cameraHeight = 480;
	
	int n = 3; // no patterns have more than 3 frames
	for(int i = 0; i < n; i++) {
		recent.push_back(ofImage());
		recent.back().allocate(
							   cameraWidth,
							   cameraHeight,
							   OF_IMAGE_COLOR);
		needsUpdate.push_back(false);
	}
	curGenerator = &threePhase;
	
	int captureTime = 15;
	imageSaver.setup(cameraWidth, cameraHeight, captureTime * 60);
	
	ofSetVerticalSync(true);
	ofSetFrameRate(60);
	
	ofBackground(0, 0, 0);
	
	scanningSound.loadSound("resources/scanningPlaceholder.mp3");
	scanningSound.setLoop(true);
	
	spotLightImage.loadImage("resources/captureMask.jpg");
	generateSpotlight(spotLightImage);
	spotLightImage.setAnchorPercent(0.5, 0.5);
	
	face.setup("faceHaar/haarcascade_frontalface_alt.xml", 320, 240, 2.0, 2.0);
	prevFaceCheckTimeF = ofGetElapsedTimef();
	
	threePhase.setSize(1024, 768);
	updateGenerator();
	
	light.setup(0);
}
Пример #10
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    // OSC
	receiver.setup(PORT);
    
	current_msg_string = 0;
	camX = -6000;
	camZ = 0;
    
    ofBackground(0, 0, 0);
    cam.setPosition(camX, 0, camZ);
    cam.lookAt(ofVec3f(0, 0, 0));
    
    // KINECT
    ofSetLogLevel(OF_LOG_VERBOSE);
    kinect.setRegistration(true);
    kinect.init();
    
    // SOUND
    sound.loadSound( "Monneista.wav" );
    sound.setLoop(false);
    
    //Set spectrum values to 0
    for (int i=0; i<N; i++) {
        spectrum[i] = 0.0f;
    }
    
    ofEnableDepthTest();
	glEnable(GL_POINT_SMOOTH); // use circular points instead of square points
	glPointSize(4);
    
    // LIGHTS
    ofSetSmoothLighting(true);
    pointLight.setDiffuseColor( ofFloatColor(.85, .85, .85) );
    pointLight.setSpecularColor( ofFloatColor(1.f, 1.f, 1.f));
    pointLight.setPosition(1000, 400, 1000);
    
    // POST-PROCESSING
    post.init(ofGetWidth(), ofGetHeight());
    post.createPass<BloomPass>()->setEnabled(true);
    post.createPass<BloomPass>()->setEnabled(true);
    post.createPass<GodRaysPass>()->setEnabled(true);
    
    //post.createPass<FxaaPass>()->setEnabled(true);
    post.createPass<DofPass>()->setEnabled(true);
    post.createPass<VerticalTiltShifPass>()->setEnabled(true);
    
    // PLANETS
    nPlanets = 726;
    myPlanet = new ofPlanet*[nPlanets]; // an array of pointers for the objects
    nSatellites = 2;
    for (float y = -165; y < 165; y += 10) {
        for (float x = -110; x < 110; x += 10) {
            myPlanet[planetCounter] = new ofPlanet(x, y, nSatellites);  // create each object from the array
            planetCounter++;
        }
    }
    
    // STARS
    nStars = 200;
    myStar = new ofStar*[nStars];
    int minRadius = 600;
    int maxRadius = 1800;
    for (int i = 0; i < nStars; i++) {
        myStar[i] = new ofStar(minRadius, maxRadius);
    }
    
}
Пример #11
0
//--------------------------------------------------------------
void ofApp::setup() {

	ofSetLogLevel(OF_LOG_VERBOSE);
	ofSetFrameRate(60);

	h = 480;
	w = 640;
	angle = 0;
	screenSectionWidth = floor(w/3);

	allowSaveMesh = false;

	kinect.setRegistration(true);
	kinect.init(false, false); // disable video image (faster fps)

	kinect.open();		// opens first available kinect

	// print the intrinsic IR sensor values
	if(kinect.isConnected()) {
		ofLogNotice() << "sensor-emitter dist: "   << kinect.getSensorEmitterDistance() << "cm";
		ofLogNotice() << "sensor-camera dist:  "   << kinect.getSensorCameraDistance() 	<< "cm";
		ofLogNotice() << "zero plane pixel size: " << kinect.getZeroPlanePixelSize() 	<< "mm";
		ofLogNotice() << "zero plane dist: " 	   << kinect.getZeroPlaneDistance() 	<< "mm";
	}

	kinectAngle.addListener(this, &ofApp::angleChange);
	saveMeshBtn.addListener(this, &ofApp::saveMesh);

	cameraUpDwn.addListener(this, &ofApp::cameraUpDwnChange);

	topLimit.addListener(this, &ofApp::topLimitChange);
	botLimit.addListener(this, &ofApp::botLimitChange);
	leftLimit.addListener(this, &ofApp::leftLimitChange);
	rightLimit.addListener(this, &ofApp::rightLimitChange);

	nearThreshold.addListener(this, &ofApp::nearThresholdChange);
	farThreshold.addListener(this, &ofApp::farThresholdChange);

	// ui
	gui.setup();

	gui.add(cameraUpDwn.setup( "Camera Up/Dwn", 0, -500, 500 ));
	gui.add(cameraInOut.setup( "Camera In/Out", 670, 0, 1000 ));

	gui.add(nearThreshold.setup( "Near Threshold", 0, 0, KINECT_MAX_THRESHOLD ));
	gui.add(farThreshold.setup( "Far Threshold", KINECT_MAX_THRESHOLD, 0, KINECT_MAX_THRESHOLD ));

	gui.add(topLimit.setup("top", 0, 0, 480));
	gui.add(botLimit.setup("bot", 480, 0, 480));
	gui.add(leftLimit.setup("left", 0, 0, 640));
	gui.add(rightLimit.setup("right", 640, 0, 640));
	gui.add(kinectAngle.setup("angle", 0, -15, 15));
	gui.add(pointStep.setup("point step", 1, 1, h/2));
	gui.add(saveMeshBtn.setup("SAVE"));

	// mesh
	mesh.setMode(OF_PRIMITIVE_POINTS);

	// camera
	cam.setPosition(ofVec3f(0,0,0));
	centreNode.setPosition(ofVec3f(0,0,0));
	cam.lookAt(centreNode);

	// serial
	AD1.listDevices();
	AD1.setup("COM6", BAUD_RATE);

	resetDetectionVariables();
}
Пример #12
0
//--------------------------------------------------------------
void testApp::setup() {
	
	ofSetVerticalSync(true);
	ofBackgroundHex(0x333333);
	ofSetLogLevel(OF_LOG_NOTICE);
    
    
    ofSetCircleResolution(200);
    
	
    numCategories = 5;

    
	box2d.init();
	box2d.setFPS(30.0);
    box2d.registerGrabbing();
    box2d.setGravity(-32, 32);
    box2d.createBounds();
		
	for (int i=0; i<20; i++) {
		
		
		float r = ofRandom(30, 50);		
		float rx = ofRandom(55, ofGetWidth()-55);		        
		float ry = ofRandom(10, ofGetHeight()-10);		        
		ofxBox2dCircle circle;
        
		circle.setPhysics(.2, 0.2, .8);
		circle.setup(box2d.getWorld(), rx, ry, 40);
		circles.push_back(circle);
        
        for(int i=0; i<numCategories; i++) {
            tempPoint.x = ofGetWidth()/2 + 200*cos(i*PI*2/numCategories);
            tempPoint.y = ofGetHeight()/2 + 200*sin(i*PI*2/numCategories);
            centerPoints.push_back(tempPoint);
        }
        
        for(int i=0; i<circles.size(); i++) {
            tempBool = false;
            isTrash.push_back(tempBool);
            tempBool = false;
            isSaved.push_back(tempBool);
            circles[i].enableGravity(false);
            
            tempInt = i%numCategories;
            whichCategory.push_back(tempInt);

        }
        
//        emailUserData* tempStruct = new emailUserData;
//        tempStruct->category = 3; 
//        circles[0]->setUserData(tempStruct);
//        
//        emailUserData* udStruct = (emailUserData*)circles[0]->GetUserData();
//        
//        cout << udStruct;
		
        
        
//		float w = ofRandom(4, 20);	
//		float h = ofRandom(4, 20);	
//		ofxBox2dRect rect;
//		rect.setPhysics(1.0, 0.53, 0.3);
//		rect.setup(box2d.getWorld(), ofGetWidth()/2, ofGetHeight()/2, w, h);
//		boxes.push_back(rect);
	}
		
}
Пример #13
0
//--------------------------------------------------------------
void testApp::setup() {
    
    
    /*  INTRO   */
    
    // Preamble
    cout << "Starting Program " << endl;
    cout << " ----- \n" << endl;
    
    // Set Log Level (To Ensure Serial Debug Info Prints)
    ofSetLogLevel(OF_LOG_NOTICE);
    
    // Read Credentials File
    credentials = ofBufferFromFile("settings/credentials.txt");
    host = credentials.getFirstLine();
    username = credentials.getNextLine();
    password = credentials.getNextLine();
    port = credentials.getNextLine();
    
    // Set Paths
    pathToDataDirectory = "../../../MEDIA";
    pathToLogsDirectory = "../../../LOGS";
    pathToUploadsDirectory = "/filefrontend/data/files/uploads/";
    
    
    /*  READ EXISTING FILES */
    
    // Set Path To Root Data Folder
    string mediaPath = pathToDataDirectory;
    mediaDirectory = ofDirectory(mediaPath);
    
    //Allow Media Types
    mediaDirectory.allowExt("jpg");
    mediaDirectory.allowExt("png");
    mediaDirectory.allowExt("mp4");
    mediaDirectory.allowExt("zip");
    
    // List
    mediaDirectory.sort();
    mediaDirectory.listDir();
    cout << "Media Directory Has " << mediaDirectory.size() << " Valid Files \n" << endl;
    existingFileNames.resize(mediaDirectory.size());
    for (int i = 0; i < mediaDirectory.size(); i++) {
        existingFileNames[i] = mediaDirectory.getName(i);
        cout << "Existing File Name #" << i << " is " << existingFileNames[i] << endl;
    }
    
    cout << "Existing Parse Success! \n" << endl;
    
    // Connect
    try {
        cout << "Attempting To Connect To FTP:" << endl;
        
        // Log In To FTP
        client.setup(host, username, password, 21);
        client.setVerbose(true);
        
        cout << "Connection Success! \n" << endl;
    }
    catch(int e) {
        cout << "The Exception #" << e << " Occured." << endl;
    }
    
    
    /*  LIST REMOTE FILES */
    
    // List Files
    try {
        cout << "Attempting To List All Files:" << endl;

        // Assign List Of Directory To Base String Vector
        fileNames = client.list(pathToUploadsDirectory);
        
        // Resize Trimmed Vector To Match
        trimmedFileNames.resize(fileNames.size());
        existingFileNames.resize(trimmedFileNames.size());

        // Loop Through File Names, Trim At Path, And Assign To New Vector
        for(int i = 0; i < fileNames.size(); i++) {
            cout << "Original Item #" << i << " is " << fileNames[i] << endl;
            vector<string> trimmedName = ofSplitString(fileNames[i], "uploads/");
            trimmedFileNames[i] = trimmedName[1];
        }
        
        cout << "" << endl;
        
        // Loop Through New Vector To Make Sure
        for(int i = 0; i < trimmedFileNames.size(); i++) {
            cout << "Trimmed Item #" << i << " is " << trimmedFileNames[i] << endl;
        }
        
        cout << "Listing Success!\n" << endl;
    }
    catch(int e) {
        cout << "The Exception #" << e << " Occured." << endl;
    }
    
    
    /*  COMPARE EXISTING AND REMOTE FILES */
    
    // Compare Files
    cout << "Attempting To Compare All Files:" << endl;
    
    for(int i = 0; i < trimmedFileNames.size(); i++) {
        Boolean match = false; // Set Boolean To Test Matches
        for(int j = 0; j < existingFileNames.size(); j++) {
            // If The Current File Matches Any File In The Existing List
            if(trimmedFileNames[i].compare(existingFileNames[j]) == 0 ) {
                match = true;
                break;
            }
            // Otherwise Mark It As New
            else {
                match = false;
            }
        }
        
        // Test
        if(match) {
            cout << "The File " << trimmedFileNames[i] << " Has Previously Been Downloaded" << endl;
        }
        else {
            cout << "The File " << trimmedFileNames[i] << " Seems To Be New" << endl;
            newFileNames.push_back(trimmedFileNames[i]); // Add To New List
        }
    }
    
    cout << "Comparing Success!\n" << endl;
    
    
    /*  DOWNLOAD NEW FILES */
    
    // Get Files
    try {
        cout << "Attempting To Download " << newFileNames.size() << " Files:" << endl;
        
        // Download All Files From Uploads Directory To Data Directory
        for(int i = 0; i < newFileNames.size(); i++) {
            cout << "Downloading The File " << newFileNames[i] << endl;
            client.get(newFileNames[i], ofToDataPath(""), pathToUploadsDirectory);
        }
        
        cout << "Downloading Success!\n" << endl;
    }
    catch(int e) {
        cout << "The Exception #" << e << " Occured." << endl;
    }
    
    
    /*  MOVE FILES */
    
    cout << "Listing Files In Data Directory" << endl;
    
    // Set Path To Root Data Folder
    string dataPath = "";
    dataDirectory = ofDirectory(dataPath);
    
    //Allow Media Types
    dataDirectory.allowExt("jpg");
    dataDirectory.allowExt("png");
    dataDirectory.allowExt("mp4");
    dataDirectory.allowExt("zip");
    
    // List
    dataDirectory.sort();
    dataDirectory.listDir();
    cout << "Data Directory Has " << dataDirectory.size() << " Valid Files" << endl;
    
    // Move To Data Directory
    cout << "Moving To Data Directory" << endl;
    for (int i = 0; i < dataDirectory.size(); i++) {
        ofFile file = dataDirectory.getFile(i);
        cout << "Moving File #" << i << endl;
        file.moveTo(pathToDataDirectory, true, false);
    }
    
    cout << "Moving Success!\n" << endl;
    
}
Пример #14
0
// ------------------------------------------------------------------------------------------------------
//
void ofApp::setup()
{
	ofBackground( ofColor::white );
	
	ofSetLogLevel(OF_LOG_VERBOSE);
	
	fontSmall.loadFont("Fonts/DIN.otf", 8 );
	
	currAppMode = APP_MODE_LIVE;

	ofxGuiSetFont( "Fonts/DIN.otf", 8 );
	ofxGuiSetDefaultWidth( 260 );

	// Set up UI
	string xmlSettingsPath = "Settings/Main.xml";
	gui.setup( "Main", xmlSettingsPath );
	
	gui.add( kinectPointCloudScale.set( "Kinect Point Cloud Scale", 0.05, 0.0, 1.0 ) );
	gui.add( kinectPointCloudOffset.set( "Kinect Point Cloud Offset", ofVec3f(0,0,0), ofVec3f(-500,-500,-500), ofVec3f(500,500,500) ) );
	
	gui.add( globalAmbient.set("Global Ambient", ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
	gui.add( light1Position.set( "Light 1 Position", ofVec3f(-5,50,0), ofVec3f(-200,0,-200), ofVec3f(200,400,200) ) );
	gui.add( light1Diffuse.set("Light 1 Diffuse",   ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
	gui.add( light1Ambient.set("Light 1 Ambient",   ofColor(50,50,50), ofColor(0,0,0,0), ofColor(255,255,255,255)) );
	gui.add( light1Specular.set("Light 1 Specular", ofColor(255,255,255), ofColor(0,0,0,0), ofColor(255,255,255,255)) );

	gui.add( drawPointCloud.set( "Draw Point Cloud", false ) );

	//gui.add( testPos.set( "Test Pos", ofVec3f(-5,50,0), ofVec3f(-200,0,-200), ofVec3f(200,400,200) ) );

	gui.loadFromFile( xmlSettingsPath );
	gui.minimizeAll();
	
	kinectManager.init();
	
	particles.init(); // number of particles is (texSize * texSize)
	
	ofVec2f guiPos = gui.getPosition();
	particles.gui.setPosition( guiPos + ofVec2f( gui.getWidth() + 10, 0) );
	
	// Give us a starting point for the camera
	camera.setNearClip( 0.01f );
	camera.setPosition( 0, 50, 100.0 );
	camera.setMovementMaxSpeed( 1.0f );
	
	pointCloudMesh.setMode( OF_PRIMITIVE_POINTS );
	
	time = 0.0f;
	timeStep = 1.0f / 60.0f;
	
	light[0].enable();

	opticalFlowDebugDrawer.init();
	opticalFlowDebugDrawer.getGui()->setPosition( gui.getPosition() + ofVec2f( 0, gui.getHeight() + 10) );
	
	ofSetLogLevel(OF_LOG_NOTICE);
	
	drawUI = false;
	
	//ofHideCursor();
}
Пример #15
0
//--------------------------------------------------------------
void ofApp::setup(){
	ofSetLogLevel(OF_LOG_VERBOSE);
	agua.setup(1024, 768);
}
Пример #16
0
//--------------------------------------------------------------
void ofApp::setup(){
	ofSetLogLevel(OF_LOG_VERBOSE);
	bleThread.startThread();
}
Пример #17
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetLogLevel(OF_LOG_VERBOSE);
    
    numGroupsToCreate = 3;
    login();
}
Пример #18
0
void testApp::setup() {
	ofSetVerticalSync(true);
	ofSetLogLevel(OF_LOG_VERBOSE);
	camera.setup();
}
Пример #19
0
//--------------------------------------------------------------
void Grabber::setup() {

    gdata       = new GlobalData();
    gdata->loadCalibData("settings.xml");
    ofLogLevel(OF_LOG_VERBOSE);
    //ofLogToFile("client_log.txt", false);

    setupGui();
    downsampling = 4;
    switch(gdata->sys_data->logLevel) {
        case 0: ofSetLogLevel(OF_LOG_VERBOSE); break;
        case 1: ofSetLogLevel(OF_LOG_NOTICE); break;
        case 2: ofSetLogLevel(OF_LOG_WARNING); break;
        case 3: ofSetLogLevel(OF_LOG_ERROR); break;
        case 4: ofSetLogLevel(OF_LOG_FATAL_ERROR); break;
        case 5: ofSetLogLevel(OF_LOG_SILENT); break;
        default:ofSetLogLevel(OF_LOG_VERBOSE); break;
    }

    FrameUtils::init();

    ofSetFrameRate(gdata->sys_data->fps);

    total2D     = gdata->total2D;    //Hacer que se cargue dinámico.
    total3D     = gdata->total3D;    //Hacer que se cargue dinámico.

    //ofSetFrameRate(gdata->sys_data->fps);

    if((gdata->total2D + gdata->total3D) > 0) {
        tData = new ThreadData[gdata->total2D + gdata->total3D];
        for(int w = 0; w < (gdata->total2D + gdata->total3D); w++) {
            tData[w].cliId = gdata->sys_data->cliId;
        }
    } else {
        tData = NULL;
    }

    t_camera * camera = gdata->camera;

    if(gdata->total2D > 0) {
        t2D   = new Thread2D[gdata->total2D];
    }

    if(gdata->total3D > 0) {
        t3D   = new Thread3D[gdata->total3D];
    }

    int i2D = 0;
    int i3D = 0;

    while(camera != NULL) {
        if(camera->use3D == 1) {
            t3D[i3D].sys_data                   = gdata->sys_data;
            t3D[i3D].context                    = camera;
            t3D[i3D].startThread(true, false);
            i3D ++;
        } else {
            t2D[i2D].sys_data                   = gdata->sys_data;
            t2D[i2D].context                    = camera;
            t2D[i2D].startThread(true, true);
            i2D ++;
        }
        camera = camera->sig;
    }
    ofLogVerbose() << "[Grabber::setup] " << gdata->sys_data->goLive;
    if(gdata->sys_data->goLive == 1) { //Si desde el Calibrator se indicó que se debe trasmitir en vivo.
        transmitter.grabber     = this;
        transmitter.sys_data    = gdata->sys_data;
        transmitter.startThread(true, true);
    }
    ofVideoGrabber vid;
    vid.listDevices();
}
Пример #20
0
//--------------------------------------------------------------
void testApp::setup() {
	ofSetLogLevel(OF_LOG_VERBOSE);

    ofEnableAlphaBlending();
    ofSetPolyMode(OF_POLY_WINDING_NONZERO);

    ofTrueTypeFont::setGlobalDpi(72);
    font.loadFont("GUI/dinnextroundedltprolight.ttf", 28, true, true);

    // enable depth->rgb image calibration
	kinect.setRegistration(true);

	//kinect.init();
	//kinect.init(true); // shows infrared instead of RGB video image
	kinect.init(false, false); // disable video image (faster fps)
	kinect.open();

    angle=kinect.getCurrentCameraTiltAngle();
	//kinect.setCameraTiltAngle(angle);
	//ofSleepMillis(1000);

	kinect.enableDepthNearValueWhite(true);

    ofAddListener(blob2DTracker.blobAdded, this, &testApp::blob2DAdded);
    ofAddListener(blob2DTracker.blobMoved, this, &testApp::blob2DMoved);
    ofAddListener(blob2DTracker.blobDeleted, this, &testApp::blob2DDeleted);

    blobFinder.init(&kinect, true); // standarized coordinate system: z in the direction of gravity
    blobFinder.setResolution(BF_LOW_RES);
    blobFinder.setRotation( ofVec3f( angle, 0, 0) );
    blobFinder.setTranslation(ofVec3f(0,0,0));
    blobFinder.setScale(ofVec3f(0.001, 0.001, 0.001)); // mm to meters
    // bind our kinect to the blob finder
    // in order to do this we need to declare in testApp.h: class testApp : public ofBaseApp, public ofxKinectBlobListener
    blobTracker.setListener( this );

    blobImage.allocate(kinect.width, kinect.height, OF_IMAGE_GRAYSCALE);

    background.allocate(kinect.width, kinect.height, OF_IMAGE_GRAYSCALE);
    backgroundTex.allocate(kinect.width, kinect.height);//,OF_IMAGE_GRAYSCALE);
    inPainter.setup(kinect.width, kinect.height);

    tmpMapMask = new unsigned char[kinect.width*kinect.height];
    tmpZonesMask = new unsigned char[kinect.width*kinect.height];

    nearThreshold=10000.;
    farThreshold=10000.;

    diffThreshold=100.;

    maxBlobs = 10;
    minBlobPoints=250;
    maxBlobPoints=1000000;
    // NOTE: measurement units in meters!!!
    minBlobVol = 0.02f;
    maxBlobVol = 2.0f;

    damping=10.;
    mass=1.;
    K=30.;
    /*zonesCols=3;
    zonesRows=3;
    zonesColSpacing=20;
    zonesRowSpacing=20;*/

    dilate=10;
    erode=10;

    getPitchAndRoll=false;
    pitch=0.;
    roll=0.;

    mapPoint=0;
	mapFbo.allocate(kinect.width,kinect.height);
	mapPixels.allocate(kinect.width,kinect.height,OF_IMAGE_GRAYSCALE);
    mapMask.allocate(kinect.width, kinect.height);

    zonesDistance=10.;
    zonesFbo.allocate(kinect.width,kinect.height);

    gui = new ofxUISuperCanvas("kinectMap", OFX_UI_FONT_MEDIUM);
    gui->addSpacer();
    gui->addTextArea("CONTROL", "Control de parametros de kinectMap");
    gui->addSpacer();
    gui->addSlider("angle", -30, 30, &angle);
    gui->addLabelToggle("learnBackground", &learnBackground);
    gui->addSlider("backFrames", 0.0, BACKGROUND_FRAMES, &backFrames);
    gui->addSpacer();
    gui->addSlider("maxBlobs", 0, 20, &maxBlobs);
    gui->addSlider("min blob points", 0, 2000, &minBlobPoints);
    gui->addSlider("min blob vol", 0.0, 0.2, &minBlobVol);
    gui->addSlider("max blob vol", 1., 10., &maxBlobVol);
    gui->addSpacer();
    gui->addRangeSlider("near and far threshold", 0., 5000., &nearThreshold,&farThreshold);
    gui->addSlider("diff threshold", 0., 1000., &diffThreshold);
    gui->addSpacer();
    gui->addSlider("person damping", 0., 10., &damping);
    gui->addSlider("person mass", 1., 10., &mass);
    gui->addSlider("person K", 1., 30., &K);
    gui->addSpacer();
    gui->addLabelToggle("get pitch and roll",&getPitchAndRoll);
    gui->addSlider("pitch", -180., 180., &pitch);
    gui->addSlider("roll", -180., 180., &roll);
    gui->addSpacer();
    gui->addLabelToggle("mapOpen", &mapOpen);
    gui->addSpacer();
    gui->addLabelButton("zonesNew", &zonesNew);
    gui->addLabelButton("zonesClear", &zonesClear);
    gui->addSpacer();
    gui->addSlider("dilate", 0, 20, &dilate);
    gui->addSlider("erode", 0, 20, &erode);
    gui->autoSizeToFitWidgets();
    ofAddListener(gui->newGUIEvent,this,&testApp::guiEvent);

    if(ofFile::doesFileExist("GUI/guiSettings.xml"))
        gui->loadSettings("GUI/guiSettings.xml");

    loadMap();

    loadZones();

    sender.setup(IP,PORT);

    mapOpen=false;

    zonesNew=false;
    zonesClear=false;

    rotation.makeRotationMatrix(-90-pitch,ofVec3f(1,0,0),0,ofVec3f(0,1,0),-roll,ofVec3f(0,0,1));

    learnBackground = true;
    backFrames=0.;

	ofSetFrameRate(60);

}
Пример #21
0
//--------------------------------------------------------------
void testApp::setup(){
    
    //changed for version control test
    camHeight=48023434;
    showGraphLine=false;
    //switch for controlling all analysis etc V important variable
    menuState=0;
    //some change
    camWidth=640;
    camHeight=480;
    desFrameRate=-111;// the camera framerate
    
    //set gui defaults moved to start of setup because we need these values to set sliders in gui   
    masterAnalysis.setGUIDefaults();
    //ofSetFrameRate(60);   // this produces 10 or 11 frames of latency frames in the camera feed 
    
    //30/12/11 added this as a variable becuase we will need it to calculate maxNumberOfFramesForSynthesis from guiSecs later
    frameRateWeSet=30;
    
    ofSetFrameRate(frameRateWeSet);   // this produces 5 or 6 frames of latency frames in the camera feed 
    //ofSetFrameRate(15);     // this produces 2 or 3 frames of latency frames in the camera feed 
    //ofSetFrameRate(5);   // this produces  or 1 or 2 frames of latency
    //ofSetFrameRate(1);   // this produces?  i'm not patient enough to figure this out...
    // i.e.:  the frame lag seems to be ofGetFrameRate()/6 or thereabouts.
    
    ofEnableSmoothing();
    ofSetVerticalSync(TRUE);
    //set default codec
    codecChooser=0;
    
    
    if (!mainFileHelper.doesDirectoryExist("IMAGES/")){
        mainFileHelper.makeDirectory("IMAGES/");
    }
    
    
    //default location
    locationChooser="MIDDLESBROUGH";   //
    
    //default analysis
    analysisChooser="H_SHADOWSCAPES";   
    
    //its easier to initialise the camera with default settings than mess around with bad access errors when you try and draw it;(
    setupCamera(camWidth, camHeight, 2, 120,true);    
    //set initial report
    camStatus="Camera not setup";  //    //WHY say this if we've just set up the camera?
    
    keyControlMessage1="Use 1-9 & q+w+e+r to launch the analyses";
    keyControlMessage2="'c'-cursor        'v'-video input\n'f'-fullscreen   'g'-gui    'z'-to start";
    
    font.loadFont("MONACO.TTF", 10);
    
    //AT the moment - this WILL COMPILE for 10.5 if we remove the below image loaders - problem with POCO library - see here:
    // http://forum.openframeworks.cc/index.php?topic=6351.0
    
    startImage.loadImage("resourceimages/refractiveindexstart.jpg");
    endImage.loadImage("resourceimages/refractiveindexend.jpg");
    
    /*  compiling for 10.5 - we get a bunch of POCO errors
     
     SOLUTION:  http://forum.openframeworks.cc/index.php?topic=6351.0
     
     https://github.com/openframeworks/openFrameworks/issues/387
     
     http://forum.openframeworks.cc/index.php?topic=7549.0
     
     following error appears when i try to load an image; commenting out the call to loadImage("...") makes the error go away.
     
     Undefined symbols:
     "std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)", 
     referenced from:
     Poco::Net::HTTPClientSession::proxyAuthenticateImpl(Poco::Net::HTTPRequest&)in PocoNet.a(HTTPClientSession.o)
     Poco::Net::HTTPClientSession::proxyAuthenticateImpl(Poco::Net::HTTPRequest&)in PocoNet.a(HTTPClientSession.o)
     Poco::Net::HTTPRequest::write(std::basic_ostream<char, std::char_traits<char> >&) constin PocoNet.a(HTTPRequest.o)
     Poco::Net::HTTPRequest::write(std::basic_ostream<char, std::char_traits<char> >&) constin PocoNet.a(HTTPRequest.o)
     Poco::Net::HTTPRequest::write(std::basic_ostream<char, std::char_traits<char> >&) constin PocoNet.a(HTTPRequest.o)
     Poco::Net::MessageHeader::write(std::basic_ostream<char, std::char_traits<char> >&) constin PocoNet.a(MessageHeader.o)
     Poco::Net::MessageHeader::write(std::basic_ostream<char, std::char_traits<char> >&) constin PocoNet.a(MessageHeader.o)
     Poco::Net::HTTPResponse::write(std::basic_ostream<char, std::char_traits<char> >&) constin PocoNet.a(HTTPResponse.o)
     Poco::Net::HTTPResponse::write(std::basic_ostream<char, std::char_traits<char> >&) constin PocoNet.a(HTTPResponse.o)
     ld: symbol(s) not found
     */
    
    showGui=FALSE;
    showCursor=FALSE;
    showCameraInput=FALSE;
    
    //talk to me about your troubles openframeworks
    ofSetLogLevel(OF_LOG_VERBOSE);  
    
    ////////////GUI SETUP STUFF////////////////
    
    // RI PURPLE  #716e88 =     113, 110, 136
    ofxControlPanel::setBackgroundColor(simpleColor(113, 110, 136, 200));
    ofxControlPanel::setTextColor(simpleColor(255, 255, 255, 255));
    ofxControlPanel::setOutlineColor(simpleColor(255, 255, 255, 255));   
    ofxControlPanel::setForegroundColor(simpleColor(50, 50, 50, 255));
    
    //
	gui.loadFont("MONACO.TTF", 8);		
	gui.setup("Refractive Index", 0, 0, ofGetWidth(), ofGetHeight());
	
    //FIRST PANEL HOLDS CAMERA CONTROLS
    gui.addPanel("Camera Settings", 4, false);
    gui.setWhichPanel(0);
    gui.setWhichColumn(0);
    gui.addToggle("set up camera input", "CAM_IS_GO", 0);
    gui.addButtonSlider("camera width", "CAM_WIDTH", camWidth, 1.0, 1920, true);
	gui.addButtonSlider("camera height", "CAM_HEIGHT", camHeight, 1.0, 1080, true);
    gui.addButtonSlider("desired frame rate", "FRAME_RATE", 1., 1.0, 30, true);
	gui.setWhichColumn(1);
    gui.addTextInput("text message", "input text here", 250 );
    
    //GET THE INPUT NAMES FROM THE QT VIDEO GRABBER
    vidGrabber.listDevices();
    gui.addToggle("more cam settings", "SETTINGS", 0);
    
    //A NEW PANEL
    
    //removed by Tom 27/12/11
    // gui.addPanel("Analyses", 4, false);
    
    gui.setWhichPanel(0);
    gui.setWhichColumn(1);
    
    vector<string>locationNames;
    locationNames.push_back("MIDDLESBROUGH");
    locationNames.push_back("BRADFORD");
    locationNames.push_back("BIRMINGHAM");
    locationNames.push_back("SWANSEA");
    locationNames.push_back("BRISTOL");
    locationNames.push_back("WOOLWICH");
    locationNames.push_back("DOVER");
    locationNames.push_back("BELFAST");
    locationNames.push_back("EDINRBURGH");
    locationNames.push_back("MANCHESTER");
    locationNames.push_back("LIVERPOOL");
    
    gui.addTextDropDown("location", "LOCATION", 130, locationNames);
    gui.setWhichColumn(2);
    
    //will handle which analysis we are doing this time
    //TomS 22.11.11 vector<string>analysisNames; moved to h file - this needs to be global as its now used to get the panel number when switching panel in the gui event
    
    analysisNames.push_back("H_SHADOWSCAPES");
    analysisNames.push_back("V_SHADOWSCAPES");
    analysisNames.push_back("D_SHADOWSCAPES");
    analysisNames.push_back("RELAXRATE");
    analysisNames.push_back("I_RESPONSE");
    analysisNames.push_back("SHAPE_SHADING");
    analysisNames.push_back("M_CODE");
    analysisNames.push_back("CAM_FRAMERATE");
    analysisNames.push_back("CAM_NOISE");
    analysisNames.push_back("COLOR_SINGLE");
    analysisNames.push_back("LATENCY_TEST");
    analysisNames.push_back("COLOR_MULTI");
    analysisNames.push_back("DIFF_NOISE");
    
    gui.addTextDropDown("choose analysis", "ANALYSIS_TYPE", 130, analysisNames);
    gui.setWhichColumn(3);
    /*  float maxResultA; 
     float maxNumberOfFramesForSynthesis; 
     float divisionsA; 
     bool showGraphA;*/
    
    //////ADD ONE PANEL FOR EACH ANALYSIS///// --> why did you do this again?  i.e.: why not have one Panel with a row of parameters for each analysis? so much clicking :P  JA
    for(int i = 0;i< analysisNames.size();i++){
        gui.addPanel(analysisNames[i], 4, false);
    }
    
    ///TOM 21/11/11 NOW SETTING THE CORRECT GUI ELEMENTS FOR EACH ANALYSIS, PAINFULLY, ONE BY ONE
    ///Note counterMax in the analysis class seem to do exactly the same job as maxNumberOfFramesForSynthesis which is currently connected to gui, show we merge these variables? 
    
    //This is a good effeciency, but there's a need for the default values for each of these to be different, and if one gets changed, we don't want the rest of them to have the value of that one... so is there another way to deal with it that is both efficient and allows each analysis to 'keep its state'?  - JA 11 Dec 
    
    
    //local variable for setting gui from numberofframestolastfor
    float maxFramesDividedByFrameRate = masterAnalysis.maxNumberOfFramesForSynthesis/frameRateWeSet;
    
    
    //addButtonSlider(string sliderName, string xmlName, float value , float min, float max, bool isInt);
    //H_SHADOWSCAPES GUI OPTIONS
    gui.setWhichPanel(1);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    gui.addButtonSlider("scan line width", "SCAN_LINE_WIDTH", masterAnalysis.scanLineWidth, 1, ofGetWidth(), TRUE);
    gui.addButtonSlider("scan line speed", "SCAN_LINE_SPEED", masterAnalysis.scanLineSpeed, 1, 100, TRUE);
    
    //V_SHADOWSCAPES GUI OPTIONS
    gui.setWhichPanel(2);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    gui.addButtonSlider("scan line width", "SCAN_LINE_WIDTH", masterAnalysis.scanLineWidth, 1, ofGetHeight(), TRUE);
    gui.addButtonSlider("scan line speed", "SCAN_LINE_SPEED", masterAnalysis.scanLineSpeed, 1, 100, TRUE);
    
    //D_SHADOWSCAPES GUI OPTIONS
    gui.setWhichPanel(3);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    gui.addButtonSlider("scan line width", "SCAN_LINE_WIDTH", masterAnalysis.scanLineWidth, 1, 200, TRUE);
    gui.addButtonSlider("scan line speed", "SCAN_LINE_SPEED", masterAnalysis.scanLineSpeed, 1, 100, TRUE);
    
    //RELAXRATE GUI OPTIONS
    gui.setWhichPanel(4);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    gui.addButtonSlider("max white level to ramp to", "GRAPH_MAX_RESULT", masterAnalysis.maxResultA, 1, 255, TRUE);
    gui.addButtonSlider("num of seconds to last for", "GRAPH_MAX_TIME",  maxFramesDividedByFrameRate, 1, 50, TRUE);
    gui.addButtonSlider("num of impulses", "GRAPH_NUM_DIVISIONS",  masterAnalysis.divisionsA, 1, 10, TRUE);
    gui.addToggle("show graph outlines", "SHOW_GRAPH_OUTLINE", masterAnalysis.showGraphA);
    
    vector<string>graphNames;
    graphNames.push_back("LINEAR");
    graphNames.push_back("EXPONENTIAL");
    graphNames.push_back("SQUARE_WAVE");
    graphNames.push_back("QUADRATIC");
    
    gui.addTextDropDown("RELAXRATE response curve", "GRAPH_TYPE", 130, graphNames);
    
    
    /*
     //for colour multi
     fadeTime = 20;
     everyNthFrameCaptureImage = 20; //the lower this number the more camera images we get per white level shown
     numberOfGreyLevels = 10;   //the number of grey levels we want to look at
     currentGreyLevel = numberOfGreyLevels;*/
    
    
    
    //I_RESPONSE GUI OPTIONS
    
    gui.setWhichPanel(5);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    gui.addButtonSlider("num of seconds to last for", "GRAPH_MAX_TIME",  maxFramesDividedByFrameRate, 1, 50, TRUE);
    gui.addButtonSlider("number of grey levels", "ANIMATION_TIME_LIMIT", masterAnalysis.numberOfGreyLevels, 1, 20, TRUE);
    gui.addButtonSlider("fadeTime", "ANIMATION_TIME_LIMIT", masterAnalysis.fadeTime, 1, 30, TRUE);
    gui.addButtonSlider("number of frames to grab", "ANIMATION_TIME_LIMIT", masterAnalysis.numOfFramesToGrab, 1, 500, TRUE);
    
    //SHAPE_SHADING GUI OPTIONS
    gui.setWhichPanel(6);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    gui.addButtonSlider("num of seconds to last for", "GRAPH_MAX_TIME",  maxFramesDividedByFrameRate, 1, 50, TRUE);
    gui.addButtonSlider("num of frames to grab per quadrant", "fpq",  masterAnalysis.framesPerQuadrant , 1, 150, TRUE);
    
    //M_CODE GUI OPTIONS
    gui.setWhichPanel(7);
    gui.setWhichColumn(0);
    gui.addButtonSlider("morse pause time", "MORSE_SPEED", masterAnalysis.speed, 1, 25, TRUE);
    //gui.addTextInput("morse output", "input morse here", 250 );
    //nasty hack for getting text back
    tl=gui.addTextInput("morse output", "USE_UNDERSCORES_AND_CAPS", 250 );
    gui.addToggle("GO", "GO", 0);
    
    //CAM_FRAMERATE GUI OPTIONS
    gui.setWhichPanel(8);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    
    //CAM_NOISE GUI OPTIONS
    gui.setWhichPanel(9);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    
    //COLOR_SINGLE GUI OPTIONS
    gui.setWhichPanel(10);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    
    //LATENCY_TEST GUI OPTIONS
    gui.setWhichPanel(11);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    
    //COLOR_MULTI GUI OPTIONS
    gui.setWhichPanel(12);
    cout<<gui.getWhichPanel()<<" whichPanel \n";
    gui.setWhichColumn(0);
    gui.addButtonSlider("color multi overall length", "COLORMULTI_SPEED", masterAnalysis.counterMaxColorMulti, 1, 2000, TRUE);
    gui.addToggle("GO", "GO", 0);
    
    //Tom S 21.11.11 colour multi now fades through the whole spectrum so doesn't need these any more
    //gui.addButtonSlider("red level", "RED_LEVEL", 10, 1, 255, TRUE);
    //gui.addButtonSlider("green level", "GREEN_LEVEL", 10, 1, 255, TRUE);
    //gui.addButtonSlider("blue level", "BLUE_LEVEL", 10, 1, 255, TRUE);
    
    //DIFF_NOISE GUI OPTIONS
    gui.setWhichPanel(13);
    gui.setWhichColumn(0);
    gui.addToggle("GO", "GO", 0);
    
    gui.setWhichPanel(0);
    gui.setWhichColumn(1);
    
    vector<string> names=vidGrabber.returnDeviceNames();
    cout<<names.size()<<" number of inputs found\n";
    //    masterAnalysis.setupAnalysis(camWidth, camHeight, 100, analysisChooser, locationChooser, codecChooser);//, vidGrabber);    
    
    
    //get list of codecs from movie object in analysis class
    returnedCodecNames=masterAnalysis.movieFromCamera.returnCodecNames();
    
    //CURRENTLY UNUSED
    cout<<names[names.size()-1]<<" names at 2\n";
    gui.addTextDropDown("inputs", "INPUTS", 130, names);
    gui.setWhichColumn(2);
    gui.addTextDropDown("codecs", "CODECS", 130, returnedCodecNames);
    
    //dont forget to actually set this stuff in action!
    gui.setupEvents();
	gui.enableEvents();
    //  -- this gives you back an ofEvent for all events in this control panel object
	ofAddListener(gui.guiEvent, this, &testApp::eventsIn);
    
    ////////////END OF GUI SETUP STUFF////////////////
    
    
    currentPanel=gui.getSelectedPanel();
    
    /*
     
     
     */
    
}
Пример #22
0
//--------------------------------------------------------------
void testApp::setup(){
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofEnableDepthTest();
	ofSetCircleResolution(64);
	ofSetSmoothLighting(true);
	ofEnableAlphaBlending();
	//depthcam.init();
	//depthcam.setUseTexture(false);
	//depthcam.open();
	//
	
	profCam.setup();
	profCam.setRenderBlob(true);
	dataset.loadFile("conLuz.xml");
	
	calibration.init(&profCam.kinect,&dataset);
	calibration.enableKeys();
	calibration.enableChessboardMouseControl();

	rendererInited = false;
	//calibration.finalize();
	/*cam.setPosition(0,70,100);
	cam.lookAt(ofVec3f(0,0,0));
	fbo.allocate(1024,768,GL_RGBA);
	fbo.begin();
	ofClear(0,0,0, 0);
    fbo.end();*/

	sniffer.transito = &transito;
	transito.init();
	sniffer.init();

	
	
	
	verFija = true;
	cam.setDistance(20);
	camFija.setPosition(0,7,10);
	camFija.lookAt(ofVec3f(0,7,0));
 
	 luzPuntual.setPointLight();
	 luzPuntual.setPosition(0,5,10);

	 luzDos.setDirectional();
	 luzDos.setPosition(-7,3, -5);

	 ofEnableAlphaBlending();
	
	maskShader.load("shaders/mixer");
	altoCamara = profCam.getHeight();
	anchoCamara = profCam.getWidth();
	fboMezcla.allocate(anchoCamara,altoCamara);
	fboUno.allocate(anchoCamara,altoCamara);
	fboUno.begin();
	ofClear(0,0,0,0);
	fboUno.end();
	fboMensajes.allocate(anchoCamara,altoCamara);
	fboMensajes.begin();
	ofClear(0,0,0,0);
	fboMensajes.end();
	
	mensajes.push_back(new xuMensaje("Time-to-live exceeded."));
	mensajes.push_back(new xuMensaje("Someone else out there?"));
	mensajes.push_back(new xuMensaje("UNKNOWN PACKET"));
	mensajes.push_back(new xuMensaje("Client Hello"));
	mensajes.push_back(new xuMensaje("Server Hello"));
	mensajesPintados = 0;
	//mascaraTest.loadImage("mascara.png");
	//ofLoadImage(textTest,"mascara.png"); 

	ofsetMensajes.x = 0;
	ofsetMensajes.y = 0;


	gui.addTitle("Vistas");
	gui.addContent("Compuesto",fboMezcla);

	gui.addTitle("Mensajes");
	gui.addContent("",fboMensajes);
	gui.addSlider("Escala",escalaMensajes, 0.001,1.5);
	gui.addSlider("Offset x", ofsetMensajes.x,-200,200);
	gui.addSlider("Offset y", ofsetMensajes.y, -200,200); 

	gui.addTitle("Profundidad");
	gui.addSlider("Distancia minima mm", profCam.minDist,300,1000);
	gui.addSlider("Distancia maxima mm", profCam.maxDist,1100,4000);

	gui.addTitle("Paquetes");
	gui.addContent("Vista",fboUno);
	gui.addToggle("Cambiar vista", verFija);
	gui.addSlider("Velocidad",transito.velY,0.005,1.0);
	gui.addSlider("Tope de entrada",transito.maxCount, 5,500);
	gui.addSlider("Tiempo de espera", transito.timeMax, 50,1500);
	gui.addSlider("Escala", transito.escala,0.01,2);
	gui.addColorPicker("Uno",transito.colorUno);
	gui.addColorPicker("Uno",transito.colorDos);
	gui.addColorPicker("Uno",transito.colorTres);
	gui.addColorPicker("Uno",transito.colorCuatro);
	gui.addColorPicker("Uno",transito.colorCinco);
	gui.addColorPicker("Uno",transito.colorSeis);

	//gui.addContent("Produndidad",profCam.depthTextura);

	gui.loadFromXML();
	

}
Пример #23
0
void ofAddon::fromFS(string path, string platform){

    
    
    clear();
	name = ofFilePath::getFileName(path);

    string filePath = path + "/src";
    string ofRootPath = ofFilePath::addTrailingSlash(getOFRoot()); //we need to add a trailing slash for the erase to work properly

    ofLogVerbose() << "in fromFS, trying src " << filePath;


	ofSetLogLevel(OF_LOG_NOTICE);
    getFilesRecursively(filePath, srcFiles);
	//ofSetLogLevel(OF_LOG_VERBOSE);

    for(int i=0;i<(int)srcFiles.size();i++){
    	srcFiles[i].erase (srcFiles[i].begin(), srcFiles[i].begin()+ofRootPath.length());
		//ofLogVerbose() << " srcFiles " << srcFiles[i];
    	int init = 0;
#ifdef TARGET_WIN32
    	int end = srcFiles[i].rfind("\\");
#else
        int end = srcFiles[i].rfind("/");
#endif
    	string folder = srcFiles[i].substr(init,end);
    	srcFiles[i] = pathToOF + srcFiles[i];
    	filesToFolders[srcFiles[i]] = folder;
    }

    string libsPath = path + "/libs";
    vector < string > libFiles;


	//ofSetLogLevel(OF_LOG_NOTICE);
    if (ofDirectory::doesDirectoryExist(libsPath)){
        getLibsRecursively(libsPath, libFiles, libs, platform);
    }
    //ofSetLogLevel(OF_LOG_VERBOSE);


    // I need to add libFiles to srcFiles
    for (int i = 0; i < (int)libFiles.size(); i++){
    	libFiles[i].erase (libFiles[i].begin(), libFiles[i].begin()+ofRootPath.length());
		//ofLogVerbose() << " libFiles " << libFiles[i];
    	int init = 0;
#ifdef TARGET_WIN32
    	int end = libFiles[i].rfind("\\");
#else
        int end = libFiles[i].rfind("/");
#endif
        if (end > 0){
            string folder = libFiles[i].substr(init,end);
            libFiles[i] = pathToOF + libFiles[i];
            srcFiles.push_back(libFiles[i]);
            filesToFolders[libFiles[i]] = folder;
        }

    }

    for (int i = 0; i < (int)libs.size(); i++){

        // does libs[] have any path ? let's fix if so.
#ifdef TARGET_WIN32
    	int end = libs[i].rfind("\\");
#else
        int end = libs[i].rfind("/");
#endif
        if (end > 0){

            libs[i].erase (libs[i].begin(), libs[i].begin()+ofRootPath.length());
            libs[i] = pathToOF + libs[i];
        }

    }

    // get a unique list of the paths that are needed for the includes.
    list < string > paths;
    for (int i = 0; i < (int)srcFiles.size(); i++){
        size_t found;
#ifdef TARGET_WIN32
    	found = srcFiles[i].find_last_of("\\");
#else
        found = srcFiles[i].find_last_of("/");
#endif
        paths.push_back(srcFiles[i].substr(0,found));
    }

    // get every folder in addon/src and addon/libs

    vector < string > libFolders;
    ofLogVerbose() << "trying get folders recursively " << (path + "/libs");

	// the dirList verbosity is crazy, so I'm setting this off for now.
	//ofSetLogLevel(OF_LOG_NOTICE);
    getFoldersRecursively(path + "/libs", libFolders, platform);
    vector < string > srcFolders;
    getFoldersRecursively(path + "/src", srcFolders, platform);
	//ofSetLogLevel(OF_LOG_VERBOSE);

    for (int i = 0; i < libFolders.size(); i++){
        libFolders[i].erase (libFolders[i].begin(), libFolders[i].begin()+ofRootPath.length());
        libFolders[i] = pathToOF + libFolders[i];
        paths.push_back(libFolders[i]);
    }

    for (int i = 0; i < srcFolders.size(); i++){
        srcFolders[i].erase (srcFolders[i].begin(), srcFolders[i].begin()+ofRootPath.length());
        srcFolders[i] = pathToOF + srcFolders[i];
        paths.push_back(srcFolders[i]);
    }

    paths.sort();
    paths.unique();
    for (list<string>::iterator it=paths.begin(); it!=paths.end(); ++it){
        includePaths.push_back(*it);
    }

}
Пример #24
0
//--------------------------------------------------------------
void testApp::setup(){

    ofSetLogLevel(OF_LOG_VERBOSE);

    //disable vertical Sync tooo bad with light sometimes!!!!
    ofSetVerticalSync(true);
	ofSetFrameRate(60);
	ofBackground(10, 10, 10);


    // lets make a high-res sphere //
    // default is 20 //
    ofSetSphereResolution(128);

    // radius of the sphere //
	radius		= 180.f;
	center.set(ofGetWidth()*.5, ofGetHeight()*.5, 0);

    // Point lights emit light in all directions //
    // set the diffuse color, color reflected from the light source //
    pointLight.setDiffuseColor( ofColor(0.f, 255.f, 0.f));

    // specular color, the highlight/shininess color //
	pointLight.setSpecularColor( ofColor(255.f, 255.f, 0.f));
	pointLight.setPointLight();

	 spotLight.setDiffuseColor( ofColor(255.f, 0.f, 0.f));
	spotLight.setSpecularColor( ofColor(255.f, 255.f, 255.f));

///spotlight doesn't works yet with my shader!!
/*
    // turn the light into spotLight, emit a cone of light //
    spotLight.setSpotlight();

    // size of the cone of emitted light, angle between light axis and side of cone //
    // angle range between 0 - 90 in degrees //
    spotLight.setSpotlightCutOff( 50 );

    // rate of falloff, illumitation decreases as the angle from the cone axis increases //
    // range 0 - 128, zero is even illumination, 128 is max falloff //
    spotLight.setSpotConcentration( 45 );
*/

    // Directional Lights emit light based on their orientation, regardless of their position //
	directionalLight.setDiffuseColor(ofColor(0.f, 0.f, 255.f));
	directionalLight.setSpecularColor(ofColor(255.f, 255.f, 255.f));
	directionalLight.setDirectional();

    // set the direction of the light
    // set it pointing from left to right -> //
	directionalLight.setOrientation( ofVec3f(0, 90, 0) );


	bShiny = true;
    // shininess is a value between 0 - 128, 128 being the most shiny //
	material.setShininess( 120 );
	material.setDiffuseColor(ofColor(10.0f,200.0f,0.0f,255));
    // the light highlight of the material //
    material.setSpecularColor(ofColor(255, 255, 255, 255));

	bPointLight = bSpotLight = bDirLight = true;

    shader.load("multilight");


    shader.begin();

    shader.setUniform1i("numLights",3);
    shader.end();

}
Пример #25
0
void slitScanApp::setup(){
	
	// This makes relative paths work in C++ in Xcode by changing directory to the Resources folder inside the .app bundle
	// this way you can include your images in the copy phase of the project and don't have to rely on a data/ folder for distribution
	
//	//TODO Need a XPlatform solution for this
//	#ifdef TARGET_OSX
//	ofDisableDataPath();
//    CFBundleRef mainBundle = CFBundleGetMainBundle();
//    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
//    char path[PATH_MAX];
//    CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX);
//    CFRelease(resourcesURL);
//    chdir(path);
//	#endif
//	
	ofSetVerticalSync(true);
	ofSetLogLevel(OF_LOG_VERBOSE);
		
	capacity = 20;
	
	sampleMapStrings.push_back("maps/left_to_right.png");
	sampleMapStrings.push_back("maps/right_to_left.png");
	sampleMapStrings.push_back("maps/up_to_down.png");
	sampleMapStrings.push_back("maps/down_to_up.png");
	sampleMapStrings.push_back("maps/hard_noise.png");
	sampleMapStrings.push_back("maps/soft_noise.png");
	sampleMapStrings.push_back("maps/random_grid.png");
	sampleMapStrings.push_back("maps/video_delay.png");
	
	for(int i = 0; i < sampleMapStrings.size(); i++){
		ofImage* map = new ofImage();
		map->allocate(WIDTH, HEIGHT, OF_IMAGE_GRAYSCALE);
		map->loadImage(sampleMapStrings[i]);
		sampleMaps.push_back( map );
	}
		
    colorImg.allocate(WIDTH,HEIGHT, OF_IMAGE_COLOR);
	previewImage.allocate(WIDTH, HEIGHT, OF_IMAGE_COLOR);
	warpImage.allocate(WIDTH, HEIGHT, OF_IMAGE_COLOR);
	customMap.allocate(WIDTH, HEIGHT, OF_IMAGE_GRAYSCALE);
	
	currentSampleMapIndex = 0;
	
	isDraggingLeft = false;
	isDraggingRight = false;
	isDraggingCapacity = false;
	
	isFullScreen = false;
	isPaused = false;
	
	leftClamp = 0.0f;
	rightClamp = 1.0f;
		
	changeCapacity();
	initLiveVideo();
	
	warp.setBlending(true);
	warp.setDelayMap(*(sampleMaps[0]));
	
	//load buttons
	loadYourOwn.loadImage("images/loadyourown.png");
	buttonLiveOn.loadImage("images/live_on.png");
	buttonMovieOn.loadImage("images/movie_on.png");
	buttonPauseOn.loadImage("images/pause_on.png");
	buttonPauseOff.loadImage("images/pause_off.png");
	buttonBlendingOn.loadImage("images/blending_on.png");
	buttonBlendingOff.loadImage("images/blending_off.png");
	buttonFullscreenOn.loadImage("images/fullscreen_on.png");
	buttonFullscreenOff.loadImage("images/fullscreen_off.png");
	
	leftHandle.loadImage("images/handle_left.png");
	rightHandle.loadImage("images/handle_right.png");

	frameCapacityBar.loadImage("images/capacity_full.png");
	frameCapacityText.loadImage("images/frame_capacity.png");
	
	bottomImage.loadImage("images/bottom_banner.png");
}
//--------------------------------------------------------------
// OF MAIN FUNCTIONS
//--------------------------------------------------------------
void kinactorApp::setup()
{
    
#ifdef DEBUG		
    cerr << ".... KINACTOR DEBUG MODE ...." << endl 
    << "Entering setup:" << endl;
#endif

    // GENERAL SETUP
    ofSetFrameRate(30);
    bToogleFullScreen = false;
    bFullscreen = false;
    bShowInterface = true;
    bBox = false;
    
    // INIT KINECT
    ofSetLogLevel(OF_LOG_VERBOSE);
	
	// enable depth->video image calibration
	kinect.setRegistration(true);
    
	kinect.init();
	//kinect.init(true); // shows infrared instead of RGB video image
	//kinect.init(false, false); // disable video image (faster fps)
	
	kinect.open();		// opens first available kinect
	//kinect.open(1);	// open a kinect by id, starting with 0 (sorted by serial # lexicographically))
	//kinect.open("A00362A08602047A");	// open a kinect using it's unique serial #
    

#ifdef DEBUG		
    std::cerr << "Input size: width =" << kinect.width << " height = " << kinect.height << endl;
#endif
    
    // STORE INPUT SIZE
    inputWidth = kinect.width;
    inputHeight = kinect.height;
    
    // Allocate image
    colorImg.allocate(inputWidth, inputHeight);
	grayImage.allocate(inputWidth, inputHeight);
	grayThreshNear.allocate(inputWidth, inputHeight);
	grayThreshFar.allocate(inputWidth, inputHeight);
    
    // OPENCV PARAMETERS
    nearThreshold = 250;
	farThreshold  = 100;
    blobMax=2;
	contour_min = inputWidth * inputHeight / 20;  // 1/20 della CAM
    contour_max = inputWidth * inputHeight /3;
	
    // SET KINECT ANGLE
	kinectAngle = 0;
	kinect.setCameraTiltAngle(kinectAngle);
     
    // GUIS STUFFS
    xInit = OFX_UI_GLOBAL_WIDGET_SPACING;
    dim = 24;
    guiPanelLength = 400-xInit;
    loggerH = (ofGetWindowHeight() / 3.5);
    loggerW = guiPanelLength+xInit;
    setupGUIleft();
    setupGUIright();
    setupGUIlogger();

    // OF DRAW STUFFS
    currentFormat = kinactor;
	pointCloudRotationY = 180;
	scaleFactor = 1.0;    
    // In the default draw I have an image on the left of the interface: 410 x, 10 y
	mtrx = TRANSLATE_GUIVIEW_X;
	mtry = TRANSLATE_GUIVIEW_Y;
    ofEnableSmoothing();
    ofBackground(100, 100, 100);
#ifdef DEBUG		
    cerr << "END setup" << endl;
#endif

}
Пример #27
0
//--------------------------------------------------------------
void cyrilApp::setup(){
  doResetTimers = true;
  
  ofSoundStreamSetup(0, 1, this, 44100, beat.getBufferSize(), 4);
  
  // Switch back to external data folder
  ofSetDataPathRoot("../../../data/");
  
  ofBackground(0);
  pauseProg = false;
  //lightsOn = true;
  lightsOn = true;
  isOrtho = false;
  fxOn = true;
  
  runningProg = false;
  running[0] = false;
  running[1] = false;
  running[2] = false;
  running[3] = false;
  running[4] = false;
  running[5] = false;
  running[6] = false;
  running[7] = false;
  running[8] = false;
  running[9] = false;
  error[0] = false;
  error[1] = false;
  error[2] = false;
  error[3] = false;
  error[4] = false;
  error[5] = false;
  error[6] = false;
  error[7] = false;
  error[8] = false;
  error[9] = false;

#ifdef FULL_DEBUG
	ofSetLogLevel("ofxGLEditor", OF_LOG_VERBOSE);
#endif
  
  
  editor.addCommand('z', this, &cyrilApp::toggleFx);
  editor.addCommand('f', this, &cyrilApp::toggleFullscreen);
  editor.addCommand('a', this, &cyrilApp::toggleEditor);
  editor.addCommand('d', this, &cyrilApp::toggleBackground);
  editor.addCommand('k', this, &cyrilApp::toggleLights);
  editor.addCommand('l', this, &cyrilApp::loadFile);
  editor.addCommand('s', this, &cyrilApp::saveFile);
  editor.addCommand('e', this, &cyrilApp::resetTimers);
  editor.addCommand('p', this, &cyrilApp::pauseProgram);
  editor.addCommand('r', this, &cyrilApp::runScript);
  editor.addCommand('o', this, &cyrilApp::toggleOrtho);
  
  editorVisible = true;
  
  lastSignalReport = -1;
  
  // Init evaluation stack to empty
  _state.stk = new stack<float>;
  // Initialise our own matrix stack
  // TODO: replace with call to get from current renderer?
  _state.ms = new ofMatrixStack(*ofGetWindowPtr());
  // Initialise empty paticle system
  _state.ps = new vector<Particle*>;
  // Initialise empty variable/register map
  _state.sym = new map<int, float>;
  // Initialise palettes
  _state.cs = new map<int, Palette *>;
  // Initialise sprites
  _state.img = new map<int, ofImage *>;
  _state.parent = NULL;
  _state.light = new ofLight();
  //_state.light = NULL;
  
  
  // Directory watcher for data folder
  codeWatcher.registerAllEvents(this);
  spriteWatcher.registerAllEvents(this);
  codeWatcher.addPath(ofToDataPath("code", true), true, &fileFilter);
  spriteWatcher.addPath(ofToDataPath("sprites", true), true, &fileFilter);
  
  
  (*_state.sym)[REG_X_MAX] = 640;
  (*_state.sym)[REG_Y_MAX] = 480;
  (*_state.sym)[REG_X_MID] = (*_state.sym)[REG_X_MAX] / 2.0;
  (*_state.sym)[REG_Y_MID] = (*_state.sym)[REG_Y_MAX] / 2.0;
  
  (*_state.sym)[REG_X_SCALE] = 100;
  (*_state.sym)[REG_Y_SCALE] = 100;
  (*_state.sym)[REG_Z_SCALE] = 100;
  
  (*_state.sym)[REG_PI] = PI;
  (*_state.sym)[REG_TWO_PI] = TWO_PI;
  
  (*_state.sym)[REG_PARTICLE_HEALTH] = 1;
  (*_state.sym)[REG_PARTICLE_DECAY] = 0.1;
  
  // Reserve some space for Particle System
  _state.ps->reserve(2000);
  
  // Global settings
  ofEnableDepthTest();
	ofSetVerticalSync(true);
  if (lightsOn) {
    ofEnableLighting();
    _state.light->setAmbientColor(ofColor(0,0,0));
    _state.light->setDiffuseColor(ofColor(255,255,255));
    _state.light->setSpecularColor(ofColor(255,255,255));
    _state.light->setPointLight();
    _state.light->setAttenuation(1.f,0.f,0.f);
  }
  
  autoClearBg = true;
  ofSetBackgroundAuto(true);
  
  // changed this...
  cursorVisible = true;
  //ofHideCursor();
#ifdef __APPLE__
  //CGDisplayHideCursor(NULL); // <- OK
#endif
  
  
  (*_state.sym)[REG_FRAME] = 0;
  
  edBuf.allocate();
  edBuf.begin();
  ofClear(0,0,0,0);
  edBuf.end();
  
  ofEnableAlphaBlending();
  ofEnableAntiAliasing();
  ofEnableSmoothing();
  
  isFullScreen = false;
  //ofSetFullscreen(true);
  
	//mainOutputSyphonServer.setName("Cyril Main Output");
	//mClient.setup();
  //mClient.set("","Cyril Server");
  
	// listen on the given port
	//cout << "listening for osc messages on port " << PORT << endl;
	//receiver.setup(PORT);
  
  // Configure the ofxPostProcessing effects
  _state.post = ofxPostProcessing();
  _state.post.init(ofGetWidth(), ofGetHeight());
  _state.post.setFlip(false);
  _state.kaleido = _state.post.createPass<KaleidoscopePass>();
  _state.noisewarp = _state.post.createPass<NoiseWarpPass>();
  _state.pixelate = _state.post.createPass<PixelatePass>();
  _state.bloom = _state.post.createPass<BloomPass>();
}
Пример #28
0
//--------------------------------------------------------------
void testApp::setup() {

	// SYSTEM
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofHideCursor();
	ofSetFrameRate(60);
	
	// SCREEN
    ofEnableAlphaBlending();
    ofBackground(100);
    width = ofGetWindowWidth();
    height = ofGetWindowHeight();
	
	// KINECT
	kinect.setRegistration(true);
	kinect.init();	
	kinect.open();
	if(kinect.isConnected()) {
		ofLogNotice() << "sensor-emitter dist: " << kinect.getSensorEmitterDistance() << "cm";
		ofLogNotice() << "sensor-camera dist:  " << kinect.getSensorCameraDistance() << "cm";
		ofLogNotice() << "zero plane pixel size: " << kinect.getZeroPlanePixelSize() << "mm";
		ofLogNotice() << "zero plane dist: " << kinect.getZeroPlaneDistance() << "mm";
	}
	angle = 23;
	kinect.setCameraTiltAngle(angle);
	
	// OPENCV
	colorImg.allocate(kinect.width, kinect.height);
	grayImage.allocate(kinect.width, kinect.height);
	grayThreshNear.allocate(kinect.width, kinect.height);
	grayThreshFar.allocate(kinect.width, kinect.height);
	grayBg.allocate(kinect.width, kinect.height);
	grayDiff.allocate(kinect.width, kinect.height);
	closePoints.allocate(kinect.width, kinect.height, GL_RGBA32F_ARB); 

	nearThreshold = 250;
	farThreshold = 112;
	bLearnBakground = true;
	threshold = 80;
	bThreshWithOpenCV = false;
	minBlob = 25; 
	maxBlob = (kinect.width*kinect.height)/2; 
	
	// STATE
	presenting = true;
	tooSunny = true;
	fboAge = 0; 
	imageTimer = 0; 
	playState = 1;
	currentBrightness = 0;
	targetAlpha = 155;
	
    // XML ASSETS
    assets.loadFile("xml/assets.xml");
    if( assets.loadFile("xml/assets.xml") ) {
        ofLog(OF_LOG_NOTICE, "Loaded xml file !!! \n");
        // Load Fonts
        loadFonts();
        // Load Artist Names
        loadArtists();
        // Load Media Names
        loadAssets();
    }
    else {
        ofLog(OF_LOG_ERROR, "UNABLE to load xml file :( \n");
    }

    //  INDEX
    currentIndex = 0;
    updateCurrentIndex();

    // ASSETS
    brush.loadImage("images/brush.png");
	stamp.loadImage("logo/stamp_white2.png");
	demo.loadMovie("demo/studio_in_the_city_6_promo.mp4");

    // FBO & GLSL SHADER
    setupGL(width, height);
    
    // MEMORY
    checkMemory();

	cout << "Setup Is Done \n" << endl;

}
Пример #29
0
//--------------------------------------------------------------
void testApp::setup(){
    ofEnableAlphaBlending();
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(true);

    
    statusEnergy = 0;
    
    mode = 0;
    bInited = false;
    project = NULL;
    sketchName = "mySketch";
	

    //-------------------------------------
    // get settings
    //-------------------------------------

    XML.loadFile("settings/projectGeneratorSettings.xml");
    appToRoot = XML.getValue("appToRoot", "../../../../");
    defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps");
       //-------------------------------------
    // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc)
    //-------------------------------------

    // if appToRoot is wrong, we have alot of issues.  all these paths are used in this project:

#ifdef TARGET_OSX
    string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../"));
#else
    string binPath = ofFilePath::getCurrentExeDir();
#endif

    string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot));

    addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons"));
    sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc));


    convertWindowsToUnixPath(ofRoot);
    convertWindowsToUnixPath(addonsPath);
    convertWindowsToUnixPath(sketchPath);

    // there's some issues internally in OF with non unix paths for OF root
    setOFRoot(ofRoot);



    //-------------------------------------
    // get settings
    //-------------------------------------


    //-------------------------------------
    // load font and setup the buttons
    font.loadFont("fonts/Inconsolata.otf", 14, true,false,false,0.3,90);
    titleFont.loadFont("fonts/Inconsolata.otf", 28, true,false,false,0.3,90);
    secondFont.loadFont("fonts/Inconsolata.otf", 11, true,false,false,0.3,90);
    
    //  Sketch button
    //
    button.font = &font;
    button.secondFont = &secondFont;
    button.prefix = "Name: ";
	button.topLeftAnchor.set(76, 160+40); //set top button position - others are set relative to this.
    button.setText(sketchName);
    
    button.secondaryText = "<< CLICK TO CHANGE THE NAME";
    buttons.push_back(button);

    //  Path button
    //
    button.deliminater = "/";
    button.prefix = "Path: ";
    button.setText(sketchPath);
    button.secondaryText = "<< CLICK TO CHANGE THE DIRECTORY";
	button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Platform text
    //
    button.deliminater = ", ";
    button.prefix = "Platforms: ";
    button.secondaryText = "";
    button.bDrawLong = false;
    button.secondaryText = "";
    button.bSelectable = false;
    button.setText(platform);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Addons button
    //
    button.deliminater = ", ";
    button.bDrawLong = true;
    button.prefix = "Addons: ";
    button.secondaryText = "<< CLICK TO SELECT ADDONS";
    button.bSelectable = true;
    button.setText(addons);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Generate
    //
    generateButton = button;
    generateButton.topLeftAnchor.set(906, 535);
	//generateButton.setColor(ofColor(50, 150, 255));
    generateButton.deliminater = ",";
    generateButton.prefix = "GENERATE PROJECT";
    generateButton.bSelectable = true;
    generateButton.setText("");
    generateButton.bDrawLong = false;
    
    addonButton = button;
    addonButton.topLeftAnchor.set(906, 535);
    addonButton.prefix = "<< BACK";
    addonButton.setText("");
    addonButton.bDrawLong = false;
    

    for (int i = 0; i < buttons.size(); i++){
        buttons[i].calculateRect();
    }
    addonButton.calculateRect();
    generateButton.calculateRect();

    //-------------------------------------
    // addons panels:
    //-------------------------------------

    panelCoreAddons.setup();
    panelOtherAddons.setup();

    ofDirectory addons(addonsPath);

    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);

    	if(addon.find("ofx")==0){

            if (isAddonCore(addon)){
                ofxToggle * toggle = new ofxToggle();
                panelCoreAddons.add(toggle->setup(addon,false,300));
            } else {
                bHaveNonCoreAddons = true;
                ofxToggle * toggle = new ofxToggle();
                panelOtherAddons.add(toggle->setup(addon,false,300));
            }


    	}
    }

    //-------------------------------------
    // platform panel (not used, really, but here just in case)
    //-------------------------------------
    panelPlatforms.setup();
    panelPlatforms.add(wincbToggle.setup("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC));
	panelPlatforms.add(winvsToggle.setup("windows (visual studio)", ofGetTargetPlatform()==OF_TARGET_WINVS));
	panelPlatforms.add(linuxcbToggle.setup("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX));
	panelPlatforms.add(linux64cbToggle.setup("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64));

//for ios, we need to fake that the target is ios (since we're compiling w/ osx OF)

//#define MAKE_IOS
    
#ifdef MAKE_IOS
	panelPlatforms.add(osxToggle.setup("osx (xcode)",false));
	panelPlatforms.add(iosToggle.setup("ios (xcode)",true));
#else
    panelPlatforms.add(osxToggle.setup("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX));
	panelPlatforms.add(iosToggle.setup("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE));
#endif
    
    
    // update the platforms text in the platform button
    string platforms = "";
    for (int i = 0; i < panelPlatforms.getNumControls(); i++){
        if (*((ofxToggle *)panelPlatforms.getControl(i))){
            if (platforms.length() > 0) platforms+=", ";
            platforms += ((ofxToggle *)panelPlatforms.getControl(i))->getName();

        };
    }
    buttons[2].setText(platforms);


    panelPlatforms.setPosition(10,40);
    panelCoreAddons.setPosition(10,40);
    panelOtherAddons.setPosition(330,40);
   

    logo.loadImage("images/ofw-logo.png");

    ofBackground(230,230,230);
    
    
    generateButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - generateButton.rect.width + 10 ,
                                     ofGetHeight() - generateButton.rect.height - 40);// 535);
    generateButton.calculateRect();
    
    addonButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - addonButton.rect.width + 10 ,
                                  ofGetHeight() - addonButton.rect.height - 40);// 535);
    addonButton.calculateRect();

}
Пример #30
0
//--------------------------------------------------------------
void testApp::setup() {
    ofBackground(0);
    \
    ofEnableAlphaBlending();
    ofSetLogLevel(OF_LOG_VERBOSE);
    //ofSetFrameRate(60);
    ofSetVerticalSync(false);
    // Setup UDP socket to receive data from OpenGazer
    udpSocket.Create();
    udpSocket.Bind(OG_UDP_PORT);
    udpSocket.SetNonBlocking(true);

    // initialise gaze coords
    gazeCoords[0] = -1;
    gazeCoords[1] = -1;
    gazeCoords[2] = -1;
    gazeCoords[3] = -1;

    //create an event listener for eye movement
    //ofAddListener(onEyeMoved, this, &testApp::eyeMoved);
    ofAddListener(gazeMove, (blenderWindow*)&mypropWindow, &blenderWindow::onGazeMoved);
    ofAddListener(gazeMove, (blenderWindow*)&mytdWindow, &blenderWindow::onGazeMoved);
    ofAddListener(gazeMove, (TXTWindow*)&mytxtWindow1, &TXTWindow::onGazeMoved);
    ofAddListener(gazeMove, (TXTWindow*)&mytxtWindow2, &TXTWindow::onGazeMoved);

    // Set windows positions & dimensions
    mypropWindow.set(0, 0, ofGetWindowWidth()/4, ofGetWindowHeight()/4*3);
    mytdWindow.set(ofGetWindowWidth()/4, 0, ofGetWindowWidth()/2, ofGetWindowHeight()/4*3);
    mytxtWindow1.set(ofGetWindowWidth()/4*3, 0, ofGetWindowWidth()/4, ofGetWindowHeight()/4*3);
    mytxtWindow2.set(0, ofGetWindowHeight()/4*3, ofGetWindowWidth(), ofGetWindowHeight()/4);

    //position buttons
    float posX = ofGetWindowWidth() - 64;
    float posY = ofGetWindowHeight() - 32;
    gazeTrackBtn.setImage("gaze.png");
    gazeTrackBtn.enableMouseEvents();
    gazeTrackBtn.set(posX, posY, 16, 16);
    startBtn.setImage("record.png");
    startBtn.enableMouseEvents();
    startBtn.set(posX+20, posY, 16, 16);
    cursorBtn.setImage("cursor.png");
    cursorBtn.enableMouseEvents();
    cursorBtn.set(posX+40, posY, 16, 16);


    // Initiase tasks & corresponding windows
    blenderTask* t0 = new blenderTask();
    t0->setCorrespondingWindow((blenderWindow&)mypropWindow);
    t0->setIdentifier("PROP");
    blenderTask* t1 = new blenderTask();
    t1->setCorrespondingWindow((blenderWindow&)mytdWindow);
    t1->setIdentifier("TDWN");
    //t1->timeOut = 10.f;
    blenderTask* t2 = new blenderTask();
    t2->setCorrespondingWindow((blenderWindow&)mytxtWindow1);
    t2->setIdentifier("TXT1");
    // Add the initialised task to the broker
    blenderTask* t3 = new blenderTask();
    t3->setCorrespondingWindow((blenderWindow&)mytxtWindow2);
    t3->setIdentifier("TXT2");
    broker.addTask(*t0);
    broker.addTask(*t1);
    broker.addTask(*t2);
    broker.addTask(*t3);
}