void testApp::setup(){ ofSetFrameRate(60); ofEnableAlphaBlending(); ofSetVerticalSync(true); ofBackground(32, 32, 32); ofEnableSmoothing(); tuioClient.start(3333); ofAddListener(tuioClient.cursorAdded,this,&testApp::tuioAdded); ofAddListener(tuioClient.cursorRemoved,this,&testApp::tuioRemoved); ofAddListener(tuioClient.cursorUpdated,this,&testApp::tuioUpdated); /////////////////////////////////////// _defaultRenderer = ofGetCurrentRenderer(); sceneManager = ofxSceneManager::instance(); cheapComm *myComm; myComm=cheapComm::getInstance(); myComm->setup(); menu *m1=new menu(); m1->setTuio(&tuioClient); sceneManager->addScene( m1, SCENE_MENU); electromagnetica *electrom=new electromagnetica(); // electrom->setComm(&myComm); sceneManager->addScene( electrom, SCENE_EM); nuclear_debil *nuclear_d = new nuclear_debil(); // nuclear_d->setComm(&myComm); sceneManager->addScene( nuclear_d, SCENE_NUC_D); nuclear_fuerte *nuclear_f = new nuclear_fuerte(); // nuclear_d->setComm(&myComm); sceneManager->addScene( nuclear_f , SCENE_NUC_F); gravedad *grave=new gravedad(); // grave->setComm(&myComm); sceneManager->addScene( grave, SCENE_GRAVEDAD); sceneManager->setDrawDebug(false); sceneManager->setCurtainDropTime(0.3); sceneManager->setCurtainStayTime(0.1); sceneManager->setCurtainRiseTime(0.3); sceneManager->setOverlapUpdate(true); // sceneManager->goToScene(SCENE_MENU); timeToEndScene=-1; // OSC //ofAddListener(eventoOSC, this, &testApp::eventoOSC_Recibido ); if(ofToString(getenv("USER"))=="instalaciones" || ofToString(getenv("USER"))=="escaner" ){ ofLogToFile( ofToString (getenv("HOME") ) + "/machine_v_espejo_log.txt", true); } }
//-------------------------------------------------------------- void testApp::setup(){ myStatus.setup(); myModel.setup(&myStatus); ofSetFrameRate(30); if(myStatus.logmode) ofLogToFile("logOFtes.txt", true); ofSetFullscreen(myStatus.fullscreen); ofLog() << myStatus.currentMovie ; currentMovie.setPixelFormat(OF_PIXELS_RGB); decodeMode = OF_QTKIT_DECODE_PIXELS_AND_TEXTURE; currentMovie.loadMovie( "movies/"+myStatus.currentMovie, decodeMode); currentMovie.setLoopState(OF_LOOP_NONE); currentMovie.play(); movieLoaded=true; currentMovie.setSynchronousSeeking(false); myComm.setup( &myStatus ); ofAddListener(httpUtils.newResponseEvent,this,&testApp::newResponse); httpUtils.start(); //getRemoteMovie(); //getRemoteSpeed(); current_note_value=0; // print the available output ports to the console if(myStatus.midienabled){ midiOut.listPorts(); // via instance //ofxMidiOut::listPorts(); // via static too // connect midiOut.openPort(0); // by number //midiOut.openPort("IAC Driver Pure Data In"); // by name //midiOut.openVirtualPort("ofxMidiOut"); // open a virtual port } circlesize=0; if( myStatus.CITY != "mad" ){ verdana30.loadFont("AlteHaasGroteskBold.ttf", 170, true, true); verdana30.setLineHeight(34.0f); verdana30.setLetterSpacing(1.035); } else{ //Madrid verdana30.loadFont("AlteHaasGroteskBold.ttf", 25, true, true); } if( myStatus.CITY != "mad" ){ verdana_small.loadFont("verdana.ttf",17,true,true); } else verdana_small.loadFont("verdana.ttf",10,true,true); ofSetCircleResolution(100); sender.setup("127.0.0.1", 12001); //getRemoteStatus(); if(movieLoaded) currentMovie.draw(0,0); ofBackground(40, 40, 40); }
void ofApp::writeDiagnostics() { // Set File ofLogToFile("logs/ArtBoxLog.txt", true); // FPS ofLog() << "Frame Rate is " << ofToString(ofGetFrameRate()) << endl; // State ofLog() << "Current State is " << ofToString(playState) << endl; ofLog() << "Presenting State is " << ofToString(int(presenting)) << endl; }
//-------------------------------------------------------------- void testApp::setup(){ ofSetEscapeQuitsApp(false); #if defined(TARGET_WIN32) && !defined(OCULUS_RIFT) ofSetFrameRate(60); #endif ofSetVerticalSync(true); ofBackground(0); #if defined(OCULUS_RIFT) && defined(TARGET_WIN32) // ofSetWindowPosition(0,0); // ofSetWindowShape(1920*2,1080); #else #ifdef CLOUDS_RELEASE // ofSetWindowPosition(1920 + 1920*.5,1080*.5); // ofSetWindowPosition(0,0); #endif // ofSetWindowShape(1920,1080); #endif #ifdef OCULUS_RIFT ofToggleFullscreen(); #else ofSetWindowShape(1280, 720); ofSetWindowPosition(ofGetScreenWidth()/2 - 1280/2, ofGetScreenHeight()/2 - 720/2); #endif #ifdef CLOUDS_RELEASE ofHideCursor(); // Log to file instead of console. // Note that this only works with ofLog(...), not cout. if (!ofDirectory::doesDirectoryExist(GetCloudsDataPath(true) + "fml")) { ofDirectory::createDirectory(GetCloudsDataPath(true) + "fml"); } ofLogToFile(GetCloudsDataPath(true) + "fml/log_" + ofGetTimestampString() + ".log"); #endif firstFrame = true; playerSetup = false; shouldSetupPlayer = false; #ifdef OCULUS_RIFT loader.loadImage(GetCloudsDataPath() + "AppData/CLOUDS_HD_BG_DOUBLE.png"); #else loader.loadImage(GetCloudsDataPath() + "AppData/SCREEN_BG.png"); #endif }
//------------------------------------------------------------------------------ void ofApp::setup() { //ofToggleFullscreen(); ofBackground(0,0,0); ofSeedRandom(ofGetSystemTimeMicros()); ofSetLogLevel(OF_LOG_VERBOSE); ofLogToFile("Log.txt",false); font.loadFont("frabk.ttf", 26, false); settings.useHDMIForAudio = false; //default true settings.enableLooping = false; //default true settings.enableTexture = true; //default true settings.listener = this; //this app extends ofxOMXPlayerListener so it will receive events ; if(!settings.enableTexture) { settings.displayRect.width=320; settings.displayRect.height=240; settings.displayRect.x =0; settings.displayRect.y =0; } string path = "videos"; int maxvids = 100; vidreader.setup(maxvids,path); bLoading = true; bInitVids = false; bShowInfo = true; bTriggerNextMovie = false; bReceivedEvent = false; bExiting = false; bEndMovie = false; ratio = 0.0f; currentVideo = ""; curTime = ofGetElapsedTimeMillis(); prevTime = curTime; ofAddListener(loader.youTubeURLEvent, this, &ofApp::receivedYouTubeURLEvent); getNewVideo(); }
//-------------------------------------------------------------- void ofApp::setup(){ ofLogToFile("log.txt", true); //ofSetLogLevel(OF_LOG_VERBOSE); ofSetFrameRate(60); ofSetVerticalSync(true); ofEnableAlphaBlending(); TIME_SAMPLE_SET_FRAMERATE(60); // TIME_SAMPLE_ENABLE(); // setup ofxRemoteUI RUI_SETUP(); RUI_SET_CALLBACK(ruiServerCallback); // TODO: setup params here RUI_NEW_GROUP("App"); RUI_DEFINE_VAR_WV(bool, "app-fullscreen", false); RUI_LOAD_FROM_XML(); }
void taskBroker::saveResults() { string filename = ofToString(ofGetUnixTime()); ofLogToFile(filename); std::vector<blenderTask*>::iterator it = measuredTasks.begin(); while (it != measuredTasks.end()) { float tactiv = (*it)->windowActiveTime - (*it)->startTime; float ttotal = (*it)->endTime - (*it)->startTime; ofLog() << ";" << (*it)->countId << ";" << (*it)->identifier << ";" << (*it)->startTime << ";" << tactiv << ";" << ttotal << ";" << (*it)->result; ++it; } ofLogToConsole(); }
void Logger::createNewLog(){ ofLogToFile("./log_"+Util::currentDateTime()+".txt", true); }
Logger::Logger() { ofLogToFile("log_"+Util::currentDateTime()+".txt", true); // ofLogToFile("log.txt", true); }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetWindowShape(WIDTH, HEIGHT); ofSetWindowPosition((ofGetScreenWidth() - ofGetWidth()) / 2, (ofGetScreenHeight() - ofGetHeight()) / 2); ofSetFrameRate(60); ofDisableArbTex(); //ofSetVerticalSync(true); #ifdef SHIPPING ofLogToFile(ofVAArgsToString("logs/%s_log.txt", ofGetTimestampString("%Y-%m-%d-%H-%M-%S").c_str())); ofHideCursor(); bDebugVisible = false; isFullscreen = true; switchScreenSize(isFullscreen); #endif { ofLog(OF_LOG_NOTICE, "application start with resolution: %u x %u", ofGetWidth(), ofGetHeight()); } { const string theme_path = "fonts/theme.xml"; ofVec2f gui_pos; ofxGuiGroupRef gui; auto getNextPosition = [&]() -> ofVec2f { return gui->getPosition() + ofVec2f(gui->getWidth(), 0); }; mSettings.setName("settings"); mSettings.add(gThreshold.set("threshold", 128.0f, 0.0f, 255.0f)); mUniforms.setName("uniforms"); mUniforms.add(uDeltaTime.set("uDeltaTime", 0.0f, 0.0f, 1.0f)); mUniforms.add(uElapsedTime.set("uElapsedTime", ofGetElapsedTimef())); gui.reset(new ofxGuiGroup); loadGuiTheme(gui, theme_path); gui->setup("gui"); gui->add(mSettings); gui->add(mUniforms); gui_pos = getNextPosition(); mGui.push_back(gui); gui.reset(new ofxGuiGroup); loadGuiTheme(gui, theme_path); ofParameterGroup infos; infos.setName("hot key"); infos.add(ofParameter<string>().set("ESC", "exit")); infos.add(ofParameter<string>().set("F1", "gui")); infos.add(ofParameter<string>().set("F5", "reload shaders")); infos.add(ofParameter<string>().set("F11", "fullscreen")); infos.add(ofParameter<string>().set("S", "save settings")); infos.add(ofParameter<string>().set("L", "load settings")); infos.setSerializable(false); gui->setup("info"); gui->add(infos); gui->setPosition(gui_pos); gui_pos = getNextPosition(); mGui.push_back(gui); for (auto& g : mGui) { g->loadFromFile(getGuiFilename(g)); g->saveToFile(getGuiFilename(g)); } } { ofXml xml; if (xml.load("settings/config.xml")) { spout_prefix = xml.getValue("spout_prefix"); num_spout = xml.getValue<int>("num_spout"); screen_width = xml.getValue<int>("screen_width"); screen_height = xml.getValue<int>("screen_height"); offset_width = xml.getValue<int>("offset_width"); offset_height = xml.getValue<int>("offset_height"); ofLog(OF_LOG_NOTICE, "get config setting:\nspout_prefix: %s\nnum_spout: %u\nscreen_width: %u\nscreen_height: %u\noffset_width: %u\noffset_height: %u", spout_prefix, num_spout, screen_width, screen_height, offset_width, offset_height); if (num_spout > 0) { bundles.resize(num_spout); for (int i = 0; i < bundles.size(); i++) { string channel_name = ofVAArgsToString("%s_%u - Resolume Arena", spout_prefix.c_str(), i); printf("create spout receiver with channel name: %s\n", channel_name.c_str()); bundles[i].receiver.init(channel_name); } } } } { ofFbo::Settings s; s.width = screen_width * num_spout; s.height = screen_height; s.useDepth = false; s.colorFormats.emplace_back(GL_RGBA); mFbo.reset(new ofFbo); mFbo->allocate(s); } }
//-------------------------------------------------------------- void testApp::update() { // Screen ofBackground(0); // Age FBO if(fboAge < 100) { fboAge++; } if(playState < 2) { kinect.update(); if(kinect.isFrameNew()) { // RGB if(tooSunny) { colorImg.setFromPixels(kinect.getPixels(), kinect.width, kinect.height); colorImg.mirror(false, true); grayImage = colorImg; // Set Timer For New BG if(ofGetMinutes() % 1 == 0) { bLearnBakground = true; } // Learn A New Background Image if (bLearnBakground == true){ grayBg = grayImage; bLearnBakground = false; } // take the abs value of the difference between background and incoming and then threshold: grayDiff.absDiff(grayBg, grayImage); grayDiff.threshold(threshold); // update the cv images grayImage.flagImageChanged(); // Find The Blobs contourFinder.findContours(grayDiff, minBlob, maxBlob, 20, false); } // IR else { grayImage.setFromPixels(kinect.getDepthPixels(), kinect.width, kinect.height); grayImage.mirror(false, true); if(bThreshWithOpenCV) { grayThreshNear = grayImage; grayThreshFar = grayImage; grayThreshNear.threshold(nearThreshold, true); grayThreshFar.threshold(farThreshold); cvAnd(grayThreshNear.getCvImage(), grayThreshFar.getCvImage(), grayImage.getCvImage(), NULL); } else { unsigned char * pix = grayImage.getPixels(); int numPixels = grayImage.getWidth() * grayImage.getHeight(); for(int i = 0; i < numPixels; i++) { if(pix[i] < nearThreshold && pix[i] > farThreshold) { pix[i] = 155; } else { pix[i] = 0; } } } // update the cv images grayImage.flagImageChanged(); // Find The Blobs contourFinder.findContours(grayImage, minBlob, maxBlob, 20, false); } } // new frame // Are There Blobs ? if (contourFinder.nBlobs > 0 ) { // Draw Logo Into FBO and Fade Everything Else closePoints.begin(); ofFill(); ofSetColor(ofColor(0, 2)); ofRect(0, 0, closePoints.getWidth(), closePoints.getHeight()); ofSetColor(ofColor::white); stamp.draw(75, 0, closePoints.getWidth()- 130, closePoints.getHeight()); closePoints.end(); // Loop Through All The Blobs for (int i = 0; i < contourFinder.nBlobs; i ++) { ofVec2f frontPoint = ofVec2f (0, 0); unsigned char * pix = grayImage.getPixels(); grayImage.setFromPixels(kinect.getDepthPixels(), kinect.width, kinect.height); // ??? int tempBright; int brightPixel = grayImage.getWidth()*contourFinder.blobs[i].boundingRect.getMinY() +contourFinder.blobs[i].boundingRect.getMinX(); tempBright = pix[brightPixel]; for (int j = contourFinder.blobs[i].boundingRect.getMinY(); j <= contourFinder.blobs[i].boundingRect.getMaxY(); j++){ for (int k = contourFinder.blobs[i].boundingRect.getMinX(); k <= contourFinder.blobs[i].boundingRect.getMaxX(); k++){ int brightestPixelCandidate = (grayImage.getWidth()*j+k); if (pix[brightestPixelCandidate] > tempBright) { tempBright = pix[brightestPixelCandidate]; frontPoint = ofVec2f(k,j); } } } // Trace The Contour Into A Shape ofPath blobShape ; for (int p = 0; p < contourFinder.blobs[i].pts.size(); p++) { blobShape.lineTo(contourFinder.blobs[i].pts[p]); } // Draw That Shape Into The FBO if(fboAge > 90) { closePoints.begin(); ofFill(); ofSetColor(ofColor(0,0,255)); blobShape.setFillColor(ofColor::red); blobShape.draw(); closePoints.end(); } blobShape.clear(); } } // No Blobs else { // Still Draw The Logo & Fade closePoints.begin(); ofFill(); ofSetColor(ofColor(0, 2)); ofRect(0, 0, closePoints.getWidth(), closePoints.getHeight()); ofSetColor(ofColor::white); stamp.draw(75, 0, closePoints.getWidth()- 130, closePoints.getHeight()); closePoints.end(); } // Update FBOs maskFbo.begin(); ofSetColor(ofColor::aliceBlue); // Color ?? closePoints.draw(-250, -250, maskFbo.getWidth() + 450, maskFbo.getHeight() +250); // Magic Numbers ?? maskFbo.end(); fbo.begin(); ofClear(0, 0, 0, 0); shader.begin(); shader.setUniformTexture("maskTex", maskFbo.getTextureReference(), 1); thumbnail.draw(0, 0); shader.end(); fbo.end(); // Check Brightness Every Two Seconds if(ofGetFrameNum() % 60 == 0) { currentBrightness = getCurrentBrightness(); if(currentBrightness >= targetAlpha) { //Play Media if (currentAssetIsMovie) { video.stop(); video.setFrame(0); video.play(); video.setLoopState(OF_LOOP_NONE); } else { imageTimer = 0; } playState = 2; currentBrightness = 0; } } } // play state < 2 // Idle Video if(currentAssetIsMovie) { video.update(); } if(playState == 4) { demo.update(); } // Time To Write Soem Diagnostic Info To File if(ofGetMinutes() % 10 == 0) { // Set File ofLogToFile("logs/ArtBoxLog.txt", true); // FPS ofLog() << "Frame Rate is " << ofToString(ofGetFrameRate()) << endl; // State ofLog() << "Current State is " << ofToString(playState) << endl; ofLog() << "Presenting State is " << ofToString(int(presenting)) << endl; } }