void ofxTLCameraTrack::enable(){ ofxTLKeyframes::enable(); if(enabled){ ofAddListener(ofEvents().update, this, &ofxTLCameraTrack::update); } }
void ofxMSAInteractiveObject::enableMouseEvents() { ofAddListener(ofEvents.mousePressed, this, &ofxMSAInteractiveObject::_mousePressed); ofAddListener(ofEvents.mouseMoved, this, &ofxMSAInteractiveObject::_mouseMoved); ofAddListener(ofEvents.mouseDragged, this, &ofxMSAInteractiveObject::_mouseDragged); ofAddListener(ofEvents.mouseReleased, this, &ofxMSAInteractiveObject::_mouseReleased); }
void ofxMSAInteractiveObject::enableAppEvents() { ofAddListener(ofEvents.setup, this, &ofxMSAInteractiveObject::_setup); ofAddListener(ofEvents.update, this, &ofxMSAInteractiveObject::_update); ofAddListener(ofEvents.draw, this, &ofxMSAInteractiveObject::_draw); ofAddListener(ofEvents.exit, this, &ofxMSAInteractiveObject::_exit); }
ofxKeyMap::ofxKeyMap() { ofAddListener(ofEvents.keyPressed, this, &ofxKeyMap::_keyPressed); ofAddListener(ofEvents.keyReleased, this, &ofxKeyMap::_keyReleased); for (int i=0; i<NUM_KEYS; i++) keys[i]=false; }
//-------------------------------------------------------------- void wtmApp::initGUI() { // setup the graphical user interface gui = new ofxUISuperCanvas(WIRETOUCHVERSION, WINDOWWIDTH-(GUIWIDTH+WINDOWBORDERDISTANCE), WINDOWBORDERDISTANCE, GUIWIDTH, GUIHEIGHT); gui->addSpacer(); gui->addWidgetDown(new ofxUILabel("SENSOR PARAMETERS", OFX_UI_FONT_MEDIUM)); gui->addSlider(kGUIHalfwaveAmpName, 1.0, 255.0, 164, WIDGETWIDTH, WIDGETHEIGHT)->setLabelPrecision(0); gui->addSlider(kGUIOutputAmpName, 1.0, 255.0, 111, WIDGETWIDTH, WIDGETHEIGHT)->setLabelPrecision(0); gui->addSlider(kGUISampleDelayName, 1.0, 100.0, 1, WIDGETWIDTH, WIDGETHEIGHT)->setLabelPrecision(0); ofxUISlider* slider = gui->addSlider(kGUISignalFrequencyName, 60.0, 10.0, 20, WIDGETWIDTH, WIDGETHEIGHT); slider->setLabelPrecision(2); this->updateFrequencyLabel(); gui->addSpacer(); gui->addWidgetDown(new ofxUILabel("INTERPOLATION", OFX_UI_FONT_MEDIUM)); vector<string> interpolationTypes; interpolationTypes.push_back(kGUILinearName); interpolationTypes.push_back(kGUICatmullName); interpolationTypes.push_back(kGUICosineName); interpolationTypes.push_back(kGUICubicName); interpolationTypes.push_back(kGUIHermiteName); interpolationTypes.push_back(kGUIWNNName); interpolationTypes.push_back(kGUILagrangeName); ofxUIDropDownList *interpolationDropDownMenu = gui->addDropDownList(kGUIInterpolationDropDownName, interpolationTypes, WIDGETWIDTH); interpolationDropDownMenu->setAutoClose(true); interpolationDropDownMenu->getSelected().push_back(gui->getWidget(kGUICatmullName)); interpolationDropDownMenu->setShowCurrentSelected(true); gui->addSlider(kGUIUpSamplingName, 1.0, 12.0, 8, WIDGETWIDTH, WIDGETHEIGHT)->setLabelPrecision(0); gui->addSpacer(); gui->addWidgetDown(new ofxUILabel("BLOB DETECTION", OFX_UI_FONT_MEDIUM)); gui->addSlider(kGUIBlobGammaName, 0.0, 16.0, this->inputGamma, WIDGETWIDTH, WIDGETHEIGHT)->setLabelPrecision(2); gui->addSlider(kGUIBlobThresholdName, 0.0, 255.0, 161, WIDGETWIDTH, WIDGETHEIGHT)->setLabelPrecision(0); this->blobTracker->setThreshold(161); gui->addSlider(kGUIBlobVisualizationName, 0.0, 255.0, 31, WIDGETWIDTH, WIDGETHEIGHT)->setLabelPrecision(0); gui->addSlider(kGUIBlobAdaptiveThresholdRangeName, 3.0, 100.0, 41, WIDGETWIDTH, WIDGETHEIGHT); this->blobTracker->setAdaptiveThresholdRange(((int) 41) | 1); ofxUILabelToggle* toggle = gui->addLabelToggle(kGUIBlobsName, false, WIDGETWIDTH, WIDGETHEIGHT); gui->addSpacer(); gui->addWidgetDown(new ofxUILabel("CALIBRATION", OFX_UI_FONT_MEDIUM)); gui->addLabelButton(kGUICalibrateName, false, WIDGETWIDTH, WIDGETHEIGHT); gui->addLabelButton(kGUIResetName, false, WIDGETWIDTH, WIDGETHEIGHT); gui->addSpacer(); gui->addWidgetDown(new ofxUILabel("CONNECTION", OFX_UI_FONT_MEDIUM)); vector <ofSerialDeviceInfo> deviceList = serial.getDeviceList(); for(int i=0; i<deviceList.size(); i++) { this->serialDevicesNames.push_back(deviceList[i].getDeviceName().c_str()); } ofxUIDropDownList *serialDeviceDropDownMenu = gui->addDropDownList(kGUISerialDropDownName, serialDevicesNames, WIDGETWIDTH); serialDeviceDropDownMenu->setShowCurrentSelected(true); serialDeviceDropDownMenu->setAutoClose(true); gui->addLabelButton(kGUIStartName, false, WIDGETWIDTH, WIDGETHEIGHT); gui->addSpacer(); ofxUILabel* firmwareLabel = new ofxUILabel(kGUIFirmwareName, OFX_UI_FONT_SMALL); gui->addWidgetDown(firmwareLabel); this->updateFirmwareVersionLabel("unknown"); ofxUILabel* fpsLabel = new ofxUILabel(kGUIFPS, OFX_UI_FONT_SMALL); gui->addWidgetDown(fpsLabel); this->updateFPSLabelWithValue(0.); gui->setWidgetColor(OFX_UI_WIDGET_COLOR_BACK, ofColor(51, 51, 51)); // slider background, button color gui->setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE_HIGHLIGHT, ofColor(41, 41, 41)); gui->setWidgetColor(OFX_UI_WIDGET_COLOR_FILL, ofColor(255, 255, 255, 140)); // font color gui->setWidgetColor(OFX_UI_WIDGET_COLOR_FILL_HIGHLIGHT, ofColor(82, 208, 207)); // pressed button gui->setColorBack(ofColor(51, 51, 52, 140)); ofAddListener(gui->newGUIEvent, this, &wtmApp::guiEvent); }
void TexturedObjectScrollView::setup(const ofRectangle& r, ScrollViewConfig cfg){ config = cfg; setPosition(ofVec2f(r.x, r.y)); Node::setSize(r.width, r.height); ofFbo::Settings fboSettings; fboSettings.width = r.width; fboSettings.height = r.height; fboSettings.useDepth = false; fboSettings.textureTarget = GL_TEXTURE_RECTANGLE_ARB; //mipmaps! fboSettings.internalformat = config.internalFormat; fboSettings.numSamples = config.numFboSamples; fboSettings.numColorbuffers = 1; fbo.allocate(fboSettings); //no antialias needed here? fbo.begin(); ofClear(0,0,0,0); fbo.end(); canvas.width = r.width; canvas.height = r.height; expandedCanvas = canvas; //used to control scrollview clipping expandedCanvas.x -= config.canvasLookAheadDist; expandedCanvas.width += config.canvasLookAheadDist * 2; scrollCanvas = expandedCanvas; xOffset = scrollInertia = 0.0f; touchID = -1; fboDirty = 0.2; autoScrolling = false; gradientR.clear(); gradientR.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); gradientR.addVertex(ofVec3f(r.width - config.scrollviewEdgeGradientWidth,0)); gradientR.addVertex(ofVec3f(r.width - config.scrollviewEdgeGradientWidth,r.height)); gradientR.addVertex(ofVec3f(r.width,0)); gradientR.addVertex(ofVec3f(r.width,r.height)); gradientR.addColor(ofColor(config.bgColor,0)); gradientR.addColor(ofColor(config.bgColor,0)); if(config.bgColor.a == 0){ gradientR.addColor(ofColor(config.bgColor,255)); gradientR.addColor(ofColor(config.bgColor,255)); }else{ gradientR.addColor(ofColor(config.bgColor)); gradientR.addColor(ofColor(config.bgColor)); } gradientL.clear(); gradientL.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); gradientL.addVertex(ofVec3f(0,0)); gradientL.addVertex(ofVec3f(0,r.height)); gradientL.addVertex(ofVec3f(config.scrollviewEdgeGradientWidth,0)); gradientL.addVertex(ofVec3f(config.scrollviewEdgeGradientWidth,r.height)); if(config.bgColor.a == 0){ gradientL.addColor(ofColor(config.bgColor,255)); gradientL.addColor(ofColor(config.bgColor,255)); }else{ gradientL.addColor(ofColor(config.bgColor)); gradientL.addColor(ofColor(config.bgColor)); } gradientL.addColor(ofColor(config.bgColor,0)); gradientL.addColor(ofColor(config.bgColor,0)); ofAddListener(eventTouchMove, this, &TexturedObjectScrollView::onTouchMove); ofAddListener(eventTouchUp, this, &TexturedObjectScrollView::onTouchUp); ofAddListener(eventTouchDown, this, &TexturedObjectScrollView::onTouchDown); }
void TextureEditor::registerAppEvents() { ofAddListener(ofEvents().update, this, &TextureEditor::update); }
//Blob Callbacks void Calibration::enableBlobEventCallbacks() { ofAddListener(blobTracker.blobAdded, this, &Calibration::blobAdded); ofAddListener(blobTracker.blobMoved, this, &Calibration::blobMoved); ofAddListener(blobTracker.blobDeleted, this, &Calibration::blobDeleted); }
void Calibration::enableKeyEventCallbacks() { ofAddListener(ofEvents().keyPressed, this, &Calibration::onKeyPressed); }
void FboSource::addAppListeners() { ofLogNotice("FboSource") << "Adding app listeners"; ofAddListener(ofEvents().update, this, &FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); ofAddListener(ofEvents().draw, this, &FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); ofAddListener(ofEvents().exit, this, &FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); }
void run(){ { ofEvent<const int> intEvent; ofAddListener(intEvent, this, &ofApp::intListener); ofAddListener(intEvent, intFunctListener); auto listenerLambda = intEvent.newListener([&](const int & i){ lastIntFromLambda = i; }, 0); auto listenerMember = intEvent.newListener(this, &ofApp::intListenerWithToken); auto listenerFunc = intEvent.newListener(intFunctListenerWithToken); ofNotifyEvent(intEvent, 5); test_eq(lastInt, 5, "Testing int event to member function"); test_eq(lastIntWithToken, 5, "Testing int event to member function with release token"); test_eq(lastIntFromLambda, 5, "Testing int event to lambda function"); test_eq(lastIntFromCFunc, 5, "Testing int event to c function"); test_eq(lastIntFromCFuncWithToken, 5, "Testing int event to c function with release token"); intEvent.disable(); ofNotifyEvent(intEvent, 6); test_eq(lastInt, 5, "Testing disabled int event to member function"); test_eq(lastIntWithToken, 5, "Testing disabled int event to member function with release token"); test_eq(lastIntFromLambda, 5, "Testing disabled int event to lambda function"); test_eq(lastIntFromCFunc, 5, "Testing disabled int event to c function"); test_eq(lastIntFromCFuncWithToken, 5, "Testing disabled int event to c function with release token"); intEvent.enable(); ofNotifyEvent(intEvent, 6); test_eq(lastInt, 6, "Testing re-enabled int event to member function"); test_eq(lastIntWithToken, 6, "Testing re-enabled int event to member function with release token"); test_eq(lastIntFromLambda, 6, "Testing re-enabled int event to lambda function"); test_eq(lastIntFromCFunc, 6, "Testing re-enabled int event to c function"); test_eq(lastIntFromCFuncWithToken, 6, "Testing re-enabled int event to c function with release token"); ofRemoveListener(intEvent, this, &ofApp::intListener); ofRemoveListener(intEvent, &intFunctListener); listenerLambda.unsubscribe(); listenerMember.unsubscribe(); listenerFunc.unsubscribe(); ofNotifyEvent(intEvent, 5); test_eq(lastInt, 6, "Testing remove listener on int event to member function"); test_eq(lastIntWithToken, 6, "Testing remove listener on int event to member function with release token"); test_eq(lastIntFromLambda, 6, "Testing remove listener on int event to lambda function"); test_eq(lastIntFromCFunc, 6, "Testing remove listener on int event to c function"); test_eq(lastIntFromCFuncWithToken, 6, "Testing remove listener on int event to c function with release token"); } { ofEventListener listener; { ofEvent<const int> intEvent; listener = intEvent.newListener([&](const int & i){ lastIntFromLambda = i; }, 0); } listener.unsubscribe(); } { lastIntFromCFunc = 0; auto listener = selfUnregisterEvent.newListener(selfUnregister); selfUnregisterEvent.notify(5); test_eq(selfUnregisterValue, 5, "Testing remove listener on event callback, first call"); selfUnregisterEvent.notify(6); test_eq(selfUnregisterValue, 5, "Testing remove listener on event callback, second call"); } { ofEvent<void> voidEvent; ofAddListener(voidEvent, this, &ofApp::voidListener); auto listenerVoidLambda = voidEvent.newListener([&]{ toggleForVoidLambdaListener = !toggleForVoidLambdaListener; }); auto listenerVoidMember = voidEvent.newListener(this, &ofApp::voidListenerWithToken); auto listenerVoidFunc = voidEvent.newListener(voidFunc); voidEvent.notify(); test_eq(toggleForVoidListener, true, "Void event with member function"); test_eq(toggleForVoidLambdaListener, true, "Void event with lambda function"); test_eq(toggleForVoidListenerWithToken, true, "Void event with member function with release token"); test_eq(toggleVoidFunc, true, "Void event with c function"); voidEvent.disable(); voidEvent.notify(); test_eq(toggleForVoidListener, true, "Disabled void event with member function"); test_eq(toggleForVoidLambdaListener, true, "Disabled void event with lambda function"); test_eq(toggleForVoidListenerWithToken, true, "Disabled void event with member function with release token"); test_eq(toggleVoidFunc, true, "Disabled void event with c function"); voidEvent.enable(); voidEvent.notify(); test_eq(toggleForVoidListener, false, "Re-enabled void event with member function"); test_eq(toggleForVoidLambdaListener, false, "Re-enabled void event with lambda function"); test_eq(toggleForVoidListenerWithToken, false, "Re-enabled void event with member function with release token"); test_eq(toggleVoidFunc, false, "Re-enabled void event with c function"); ofRemoveListener(voidEvent, this, &ofApp::voidListener); listenerVoidLambda.unsubscribe(); listenerVoidMember.unsubscribe(); listenerVoidFunc.unsubscribe(); test_eq(toggleForVoidListener, false, "Unregistered void event with member function"); test_eq(toggleForVoidLambdaListener, false, "Unregistered void event with lambda function"); test_eq(toggleForVoidListenerWithToken, false, "Unregistered void event with member function with release token"); test_eq(toggleVoidFunc, false, "Unregistered void event with c function"); } }
//-------------------------------------------------------------- void ofApp::setup(){ // DISPLAY STATUS status = ""; // AUDIO INPUT ofSetVerticalSync(true); ofSetCircleResolution(80); ofBackground(54, 54, 54); // 0 output channels, // 2 input channels // 44100 samples per second // 256 samples per buffer // 4 num buffers (latency) soundStream.listDevices(); //if you want to set a different device id //soundStream.setDeviceID(0); //bear in mind the device id corresponds to all audio devices, including input-only and output-only devices. int bufferSize = 256; left.assign(bufferSize, 0.0); right.assign(bufferSize, 0.0); volHistory.assign(800, 0.5); // Initial volHistory.size() bufferCounter = 0; smoothedVol = 0.0; scaledVol = 0.0; pScaleVol = scaledVol; soundStream.setup(this, 0, 2, 44100, bufferSize, 4); soundStream.stop(); isRecording = false; // FONT font.loadFont("Arial", 100, true, true, true); text = "Chopin was a Polish composer and virtuoso pianist."; // SPEECH TO TEXT ofAddListener(recognizer.speechRecognizedEvent, this, &ofApp::speechRecognized); recognizer.initRecognizer(); recognizer.loadDictionaryFromFile("dictionary.txt"); recognizer.stopListening(); // MESHES mesh.setMode(OF_PRIMITIVE_LINES); mesh.enableColors(); mesh.enableIndices(); // ADD VERTICES vector<ofPath> letters = font.getStringAsPoints(text); for (int i = 0; i < letters.size(); i++) { ofMesh current = letters[i].getTessellation(); vector<ofPoint>& currentvertices = current.getVertices(); for (int j = 0; j < currentvertices.size(); j += 80) { // SPLIT MESH for (int k = j; k < j + 80; k++) { ofVec3f pos(currentvertices[k].x, currentvertices[k].y, currentvertices[k].z); mesh.addVertex(pos); mesh.addColor(ofColor(245, 58, 135)); } // CONNECT LINES float connectionDistance = 20; int numVerts = mesh.getNumVertices(); for (int a=0; a<numVerts; ++a) { ofVec3f verta = mesh.getVertex(a); for (int b=a+1; b<numVerts; ++b) { ofVec3f vertb = mesh.getVertex(b); float distance = verta.distance(vertb); if (distance <= connectionDistance) { mesh.addIndex(a); mesh.addIndex(b); } } } meshes.push_back(mesh); mesh.clear(); } } //cout << meshes.size() << endl; }
//-------------------------------------------------------------- void GuiSampleLoad::setup(AudioSampler *_audioSample1, AudioSampler *_audioSample2, AudioSampler *_audioSample3, AudioSampler *_audioSample4) { curPreset = 1; guiOffset = 0; int guiWidth = 15; int guiCanvasLength = 50; audioSample1 = _audioSample1; audioSample2 = _audioSample2; audioSample3 = _audioSample3; audioSample4 = _audioSample4; float dim = 16; float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; float length = 320-xInit; float tempGUIoffset = 180; // DRUM guiSample1 = new ofxUICanvas(10+(length+xInit),guiOffset,length+xInit*2.0,guiCanvasLength); guiSample1->addWidgetDown(new ofxUILabel("LOAD 1", OFX_UI_FONT_SMALL)); matrix1 = (ofxUIToggleMatrix*) guiSample1->addWidgetRight(new ofxUIToggleMatrix(dim*2, dim*2, 1, 6, "load 1"));// "AV MATRIX")); matrix1->setToggle(0, 0, true); guiSample1->addWidgetDown(new ofxUISpacer(length, 2)); // SINGING BOWLS guiSample2 = new ofxUICanvas(10+(length+xInit)*2.0,guiOffset,length+xInit*2.0,guiCanvasLength); guiSample2->addWidgetDown(new ofxUILabel("LOAD 2", OFX_UI_FONT_SMALL)); matrix2 = (ofxUIToggleMatrix*) guiSample2->addWidgetRight(new ofxUIToggleMatrix(dim*2, dim*2, 1, 6, "load 2"));// "AV MATRIX")); matrix2->setToggle(0, 0, true); guiSample2->addWidgetDown(new ofxUISpacer(length, 2)); // THROAT SINGING guiSample3 = new ofxUICanvas(10+(length+xInit)*3.0,guiOffset,length+xInit*2.0,guiCanvasLength); guiSample3->addWidgetDown(new ofxUILabel("LOAD 3", OFX_UI_FONT_SMALL)); matrix3 = (ofxUIToggleMatrix*) guiSample3->addWidgetRight(new ofxUIToggleMatrix(dim*2, dim*2, 1, 6, "load 3"));// "AV MATRIX")); matrix3->setToggle(0, 0, true); guiSample3->addSpacer(length, dim/5); // ICAROS guiSample4 = new ofxUICanvas(10+(length+xInit)*4.0,guiOffset,length+xInit*2.0,guiCanvasLength); guiSample4->addWidgetDown(new ofxUILabel("LOAD 4", OFX_UI_FONT_SMALL)); matrix4 = (ofxUIToggleMatrix*) guiSample4->addWidgetRight(new ofxUIToggleMatrix(dim*2, dim*2, 1, 6, "load 4"));// "AV MATRIX")); matrix4->setToggle(0, 0, true); guiSample4->addSpacer(length, dim/5); //Listener ofAddListener(guiSample1->newGUIEvent, this, &GuiSampleLoad::guiEvent); ofAddListener(guiSample2->newGUIEvent, this, &GuiSampleLoad::guiEvent); ofAddListener(guiSample3->newGUIEvent, this, &GuiSampleLoad::guiEvent); ofAddListener(guiSample4->newGUIEvent, this, &GuiSampleLoad::guiEvent); //Padding guiSample1->setDrawPadding(true); guiSample2->setDrawPadding(true); guiSample3->setDrawPadding(true); guiSample4->setDrawPadding(true); //XML preset loading }
void CloudsVisualSystemMazeGenerator::selfSetupGui() { customGui = new ofxUISuperCanvas("MAZE BUILDER", gui); customGui->copyCanvasStyle(gui); customGui->copyCanvasProperties(gui); customGui->setName("MAZE BUILDER"); customGui->setWidgetFontSize(OFX_UI_FONT_SMALL); customGui->addSpacer(); customGui->addSlider("CAM SPEED", -100, 300, &settings.cameraSpeed); customGui->addSlider("CAM HEIGHT", 0, 5000, &settings.cameraHeight); customGui->addSlider("CAM ANGLE", 0, 360, &settings.cameraAngle); customGui->addToggle("GROUND CAM", &settings.groundCam); customGui->addSlider("GCAM SPEED", 0, 1, &settings.groundCamSpeed); customGui->addSlider("GCAM LOOKAT", 0, 1, &settings.groundCamLookAt); customGui->addSpacer(); customGui->addSlider("SHOW AHEAD", 10, 150, &settings.showAhead); customGui->addSlider("FOG DENSITY", 0, .1, &settings.fogDensity); customGui->addSlider("FOG START", 0, 10000, &settings.fogStart); customGui->addSlider("FOG END", 0, 10000, &settings.fogEnd); customGui->addSpacer(); customGui->addSlider("NUM BALLS", 0, 150, &settings.numberOfBalls); customGui->addSlider("BALLS RADIUS", 0, 40, &settings.ballRadius); customGui->addSlider("BALLS SPEED", 0, 0.01, &settings.ballMaxSpeed); customGui->addSlider("WALL HEIGHT VARIANCE", 0, 1, &settings.heightRandom); float length = (customGui->getGlobalCanvasWidth()-customGui->getWidgetSpacing()*5)/3.; float dim = customGui->getGlobalSliderHeight(); customGui->addSpacer(); customGui->addToggle("LIGHT", &bLights); customGui->addSlider("LX", 0, 10000, &lightPos.x); customGui->addSlider("LY", 0, 1000, &lightPos.y); customGui->addSlider("LZ", 0, 100000, &lightPos.z); customGui->addSpacer(); customGui->addLabel("COLORS"); customGui->addLabel("FOG COLOR", OFX_UI_FONT_SMALL); customGui->addMinimalSlider("FH", 0.0, 255, &(settings.fogColor.r), length, dim)->setShowValue(true); customGui->setWidgetPosition(OFX_UI_WIDGET_POSITION_RIGHT); customGui->addMinimalSlider("FS", 0.0, 255, &(settings.fogColor.g), length, dim)->setShowValue(true); customGui->addMinimalSlider("FB", 0.0, 255, &(settings.fogColor.b), length, dim)->setShowValue(true); customGui->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN); customGui->addLabel("GROUND COLOR", OFX_UI_FONT_SMALL); customGui->addMinimalSlider("GH", 0.0, 255, &(settings.groundColor.r), length, dim)->setShowValue(true); customGui->setWidgetPosition(OFX_UI_WIDGET_POSITION_RIGHT); customGui->addMinimalSlider("GS", 0.0, 255, &(settings.groundColor.g), length, dim)->setShowValue(true); customGui->addMinimalSlider("GB", 0.0, 255, &(settings.groundColor.b), length, dim)->setShowValue(true); customGui->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN); customGui->addLabel("WALL COLOR", OFX_UI_FONT_SMALL); customGui->addMinimalSlider("WH", 0.0, 255, &(settings.wallColor.r), length, dim)->setShowValue(true); customGui->setWidgetPosition(OFX_UI_WIDGET_POSITION_RIGHT); customGui->addMinimalSlider("WS", 0.0, 255, &(settings.wallColor.g), length, dim)->setShowValue(true); customGui->addMinimalSlider("WB", 0.0, 255, &(settings.wallColor.b), length, dim)->setShowValue(true); customGui->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN); customGui->addLabel("BALL COLOR", OFX_UI_FONT_SMALL); customGui->addMinimalSlider("SH", 0.0, 255, &(settings.ballColor.r), length, dim)->setShowValue(true); customGui->setWidgetPosition(OFX_UI_WIDGET_POSITION_RIGHT); customGui->addMinimalSlider("SS", 0.0, 255, &(settings.ballColor.g), length, dim)->setShowValue(true); customGui->addMinimalSlider("SB", 0.0, 255, &(settings.ballColor.b), length, dim)->setShowValue(true); customGui->setWidgetPosition(OFX_UI_WIDGET_POSITION_DOWN); ofAddListener(customGui->newGUIEvent, this, &CloudsVisualSystemMazeGenerator::selfGuiEvent); guis.push_back(customGui); guimap[customGui->getName()] = customGui; }
void ofxRPiCameraVideoGrabber::setup(OMXCameraSettings omxCameraSettings_) { ofRemoveListener(ofEvents().update, this, &ofxRPiCameraVideoGrabber::onUpdate); OMX_ERRORTYPE error = OMX_ErrorNone; error = OMX_Init(); OMX_TRACE(error); omxCameraSettings = omxCameraSettings_; ofLogVerbose(__func__) << "omxCameraSettings: " << omxCameraSettings.toString(); if(!hasAddedExithandler) { addExitHandler(); hasAddedExithandler = true; } if(directEngine) { delete directEngine; directEngine = NULL; camera = NULL; ofLogVerbose() << "deleted directEngine"; resetValues(); } if(textureEngine) { delete textureEngine; textureEngine = NULL; camera = NULL; ofLogVerbose() << "deleted textureEngine"; resetValues(); } if (omxCameraSettings.enableTexture) { textureEngine = new TextureEngine(); textureEngine->setup(omxCameraSettings); camera = textureEngine->camera; if (omxCameraSettings.enablePixels) { enablePixels(); } }else { directEngine = new DirectEngine(); directEngine->setup(omxCameraSettings); camera = directEngine->camera; } checkBurstMode(); error = applyExposure(__func__); OMX_TRACE(error); checkFlickerCancellation(); applyAllSettings(); ofAddListener(ofEvents().update, this, &ofxRPiCameraVideoGrabber::onUpdate); }
//-------------------------------------------------------------- void ofApp::setup(){ ofHideCursor(); isFullScreen = true; DataManager::init(); displaySystemYOffset = 300; ofSetFrameRate(30); //get data from settings xml file int vsw = DataManager::settings.getAttribute("visualSystem", "width", 600); int vsh = DataManager::settings.getAttribute("visualSystem", "height", 400); int kParticles = DataManager::settings.getAttribute("visualSystem", "kparticles", 15); vs.init(vsw, vsh, kParticles); //load the test movie vs.loadTestMovie(DataManager::getTestVideoPath()); //setup event listeners gui.saveSetupButton.addListener(this, &ofApp::saveWaveSetup); gui.modeToggle.addListener(this, &ofApp::onModeToggle); gui.showKinect.addListener(this, &ofApp::onKinectToggle); gui.ledsOn.addListener(this, &ofApp::onLEDsToggle); gui.ledsOn.addListener(this, &ofApp::onSoundToggle); gui.fullscreen.addListener(this, &ofApp::fullscreenToggle); gui.setup(vsw+20); int port = DataManager::settings.getValue("ledStrips:port", 4445); //create wave objects DataManager::settings.pushTag("waves"); for(int i=0; i < DataManager::settings.getNumTags("wave"); i++){ string type = DataManager::settings.getAttribute("wave", "type", "", i); //cout<<"making a wave of type: " << type << endl; int x = DataManager::settings.getAttribute("wave", "x", 0, i); int y = DataManager::settings.getAttribute("wave", "y", 0, i); int w = DataManager::settings.getAttribute("wave", "width", 0, i); int h = DataManager::settings.getAttribute("wave", "height", 0, i); int id = DataManager::settings.getAttribute("wave", "id", i+1, i); if(type == DataManager::PANELS){ //create an instance of the wave object ds.addPanelsWave(x,y,w,h,id); } else if (type == DataManager::STRIPS){ //calculate # leds based on width int nleds = DataManager::settings.getAttribute("wave", "numLeds", 0, i); if(nleds == 0) nleds = round(.74 * w); string host = DataManager::settings.getAttribute("wave", "host", "", i); DataManager::settings.pushTag("wave",i); //create an instance of the strip object ds.addStripWave(x,y,w,h,id,lumigeekSender::ADDRESS_1,lumigeekSender::ADDRESS_2,nleds,host,port); DataManager::settings.popTag(); } } //make sure we pop back to the root after pushing... DataManager::settings.popTag(); //update the LEDwave pointer on the textManager to point to the wavesPanels controlled by Display System vs.tm.wavesPanels = ds.wavesPanels; webSocket.setup(); ofAddListener(webSocket.onGotMessage,this, &ofApp::onMessage); ofAddListener(webSocket.onNewConnection,this, &ofApp::onNewConnection); }
//-------------------------------------------------------------- void ofApp::setGUI() { vector<string> emptyList; // setup widget gui = new ofxUICanvas(0, 0, 200, 600); // default isShowGrid = true; isShowWireframe = true; isWindowOnTop = true; isFlipH = false; #ifdef TARGET_OSX isFlipV = false; #elif defined TARGET_WIN32 isFlipV = true; #endif //gui->setPadding(3); gui->setColorBack(ofxUIColor(80, 80, 80, 200)); gui->setColorFillHighlight(ofxUIColor(5, 140, 190, 255)); gui->setFont(FONT_NAME); gui->addLabel("Screen"); lblScreenName = gui->addLabel("file:", OFX_UI_FONT_SMALL); gui->addLabelButton("3D LOAD", false)->setLabelText("select 3d file.."); gui->addSpacer(); #ifdef TARGET_OSX gui->addLabel("Source"); ddlInput = gui->addDropDownList("INPUT LIST", emptyList); ddlInput->setAllowMultiple(false); ddlInput->setAutoClose(true); ddlInput->setShowCurrentSelected(true); ddlInput->setLabelText(""); gui->addSpacer(); #endif gui->addLabel("Display"); gui->addToggle("show wireframe", &isShowWireframe); gui->addToggle("show gird", &isShowGrid); #ifdef TARGET_OSX gui->addToggle("make window on top",&isWindowOnTop); #endif gui->addWidgetDown(new ofxUIToggle("flip H", &isFlipH, 18, 18)); gui->addWidgetRight(new ofxUIToggle("flip V", &isFlipV, 18, 18)); gui->addSpacer(); gui->addLabel("Camera"); //gui->setWidgetFontSize(OFX_UI_FONT_SMALL); gui->addWidgetDown(new ofxUILabelButton("add cam", false)); gui->addWidgetRight((new ofxUILabelButton("remove cam", false))); ndCamX = gui->addNumberDialer("x", -10000.0f, 10000.0f, 0.0f, 2); ndCamX->setName("CAMERA X"); ndCamY = gui->addNumberDialer("y", -10000.0f, 10000.0f, 0.0f, 2); ndCamY->setName("CAMERA Y"); ndCamZ = gui->addNumberDialer("z", -10000.0f, 10000.0f, 0.0f, 2); ndCamZ->setName("CAMERA Z"); msCamH = gui->addMinimalSlider("h", -180.0f, 180.0f, 0.0f); msCamH->setName("CAMERA H"); msCamP = gui->addMinimalSlider("p", -180.0f, 180.0f, 0.0f); msCamP->setName("CAMERA P"); msCamB = gui->addMinimalSlider("b", -180.0f, 180.0f, 0.0f); msCamB->setName("CAMERA B"); msCamFov = gui->addMinimalSlider("fov", 10.0f, 170.0f, 45.0f); msCamFov->setName("CAMERA FOV"); gui->autoSizeToFitWidgets(); gui->loadSettings("gui.xml"); // set cam values camPos = grabCam.getPosition(); ndCamX->setValue(camPos.x); ndCamY->setValue(camPos.y); ndCamZ->setValue(camPos.z); camEuler = grabCam.getOrientationEuler(); msCamH->setValue(camEuler.x); msCamP->setValue(camEuler.y); msCamB->setValue(camEuler.z); ofAddListener(gui->newGUIEvent, this, &ofApp::guiEvent); }
void DrawObject::show() { ofAddListener(ofEvents.draw, this, &DrawObject::draw); visible = true; }
//-------------------------------------------------------------------------- void testApp::setup() { doScreenshots = false; screenshotCount = 0; ofxDaito::setup("oscSettings.xml"); ofxConnexion::start(); ofAddListener(ofxConnexion::connexionEvent, this, &testApp::connexionEvent); ofxConnexion::setLed(false); frameScaleFactor = .6; frameW = 320 * frameScaleFactor; frameH = 240 * frameScaleFactor; int numParticles = frameW * frameH; SP.setup(frameW, frameH); SP.loadDirectory("input/otherTest/"); notifier.setup("network.xml"); notifier.enable(); ofAddListener(notifier.theEvent,this,&testApp::eventsIn); state = VIZAPP_PARTICLES_FREE; setupControlPanel(); if( bDebugMode == false ){ ofSetFullscreen(true); panel.hide(); } bJustLoadedUser = false; pointBrightness = .5; aberration = .02; aperture = .01; dofShader.load("shaders/DOFCloud"); sphereShader.load("shaders/SphereShader"); timeLastLoaded = ofGetElapsedTimef(); bDoUnload = false; PS.setup(numParticles); isMousePressed = false; chroma.allocate(targetWidth, targetHeight); chroma.begin(); ofClear(0, 0, 0, 255); chroma.end(); bTogglePlayer = panel.getValueB("toggle_mode"); for(int k = 0; k < PS.particles.size(); k++){ PS.particles[k].queueState(PARTICLE_FLOCKING, 0.0); } connexionCamera.setup(PS); currentMsg = "app started"; isSlow = false; slowState = 0; ofEnableAlphaBlending(); keyPressed('f'); keyPressed('h'); ofSetSphereResolution(16); }
void ofxRGBDCaptureGui::setup(){ currentTab = TabCalibrate; currentRenderMode = RenderBW; downColor = ofColor(255, 120, 0); idleColor = ofColor(220, 200, 200); hoverColor = ofColor(255*.2, 255*.2, 30*.2); //setup buttons framewidth = 640; frameheight = 480; thirdWidth = framewidth/3; btnheight = 30; btnSetDirectory = new ofxMSAInteractiveObjectWithDelegate(); btnSetDirectory->setPosAndSize(0, 0, framewidth, btnheight); btnSetDirectory->setLabel("Load Directory"); buttonSet.push_back(btnSetDirectory); btnCalibrateTab = new ofxMSAInteractiveObjectWithDelegate(); btnCalibrateTab->setPosAndSize(0, btnheight, thirdWidth, btnheight); btnCalibrateTab->setLabel("Calibrate"); buttonSet.push_back(btnCalibrateTab); currentTabObject = btnCalibrateTab; btnRecordTab = new ofxMSAInteractiveObjectWithDelegate(); btnRecordTab->setPosAndSize(thirdWidth, btnheight, thirdWidth, btnheight); btnRecordTab->setLabel("Record"); buttonSet.push_back(btnRecordTab); btnPlaybackTab = new ofxMSAInteractiveObjectWithDelegate(); btnPlaybackTab->setPosAndSize(thirdWidth*2, btnheight, thirdWidth, btnheight); btnPlaybackTab->setLabel("Playback"); buttonSet.push_back(btnPlaybackTab); btnRenderBW = new ofxMSAInteractiveObjectWithDelegate(); btnRenderBW->setPosAndSize(0, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderBW->setLabel("Blaick&White"); buttonSet.push_back(btnRenderBW); currentRenderModeObject = btnRenderBW; btnRenderRainbow = new ofxMSAInteractiveObjectWithDelegate(); btnRenderRainbow->setPosAndSize(thirdWidth, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderRainbow->setLabel("Rainbow"); buttonSet.push_back(btnRenderRainbow); btnRenderPointCloud = new ofxMSAInteractiveObjectWithDelegate(); btnRenderPointCloud->setPosAndSize(thirdWidth*2, btnheight*2+frameheight, thirdWidth, btnheight); btnRenderPointCloud->setLabel("Pointcloud"); buttonSet.push_back(btnRenderPointCloud); btnRecordBtn = new ofxMSAInteractiveObjectWithDelegate(); btnRecordBtn->setPosAndSize(0, btnheight*3+frameheight, framewidth, btnheight); btnRecordBtn->setLabel("Capture Chessboard"); buttonSet.push_back(btnRecordBtn); for(int i = 0; i < buttonSet.size(); i++){ buttonSet[i]->setIdleColor(idleColor); buttonSet[i]->setDownColor(downColor); buttonSet[i]->setHoverColor(hoverColor); buttonSet[i]->disableKeyEvents(); buttonSet[i]->setDelegate(this); } previewRect = ofRectangle(0, btnheight*2, 640, 480); calibrationPreview.setup(10, 7, 2.5); alignment.setup(10, 7, 2.5); alignment.setupGui(0, btnheight*4+frameheight, ofGetWidth()); timeline.setup(); timeline.getColors().loadColors("defaultColors.xml"); timeline.setOffset(ofVec2f(0,btnRecordBtn->y+btnRecordBtn->height)); timeline.addElement("depth sequence", &depthSequence); timeline.setWidth(ofGetWidth()); timeline.setLoopType(OF_LOOP_NORMAL); depthSequence.setup(); ofxXmlSettings defaults; if(defaults.loadFile("defaults.xml")){ loadDirectory(defaults.getValue("currentDir", "")); } else{ loadDirectory("depthframes"); } updateTakeButtons(); cam.setup(); cam.loadCameraPosition(); cam.speed = 25; cam.setFarClip(50000); ofRegisterMouseEvents(this); ofRegisterKeyEvents(this); ofAddListener(ofEvents().windowResized, this, &ofxRGBDCaptureGui::windowResized); //ofAddListener(ofEvents().exit, this, &ofxRGBDCaptureGui::exit); ofAddListener(ofEvents().exit, this, &ofxRGBDCaptureGui::exit); ofAddListener(ofEvents().update, this, &ofxRGBDCaptureGui::update); ofAddListener(ofEvents().draw, this, &ofxRGBDCaptureGui::draw); createRainbowPallet(); depthImage.allocate(640, 480, OF_IMAGE_COLOR); recorder.setup(); }
void TextureEditor::registerKeyEvents() { ofAddListener(ofEvents().keyPressed, this, &TextureEditor::keyPressed); ofAddListener(ofEvents().keyReleased, this, &TextureEditor::keyReleased); }
void shelfApp::setup(){ ofSetVerticalSync(true); ofSetFrameRate(60); ofBackground(0,0,0); font.loadFont("digital7.ttf", 60); fontSmall.loadFont("digital7.ttf", 20); ofSetColor(255,0,0); ard.connect("/dev/tty.usbmodemfd131", 57600); //ard.connect("/dev/ttyUSB0", 57600); // listen for EInitialized notification. this indicates that // the arduino is ready to receive commands and it is safe to // call setupArduino() ofAddListener(ard.EInitialized, this, &shelfApp::setupArduino); bSetupArduino = false; // flag so we setup arduino when its ready, you don't need to touch this :) threshold = 300; mode = PRICE; // default framerate = 60 ofSetFrameRate(45); // ITEM 1: MILK item1_price[0] = 1.99; item1_price[1] = 3.49; item1_price[2] = 3.99; item1_price[3] = 2.99; item1_price[4] = 2.99; item1_calories[0] = 200; item1_calories[1] = 900; item1_calories[2] = 378; item1_calories[3] = 506; item1_calories[4] = 506; item1_fatrate[0] = 20; item1_fatrate[1] = 14; item1_fatrate[2] = 40; item1_fatrate[3] = 70; item1_fatrate[4] = 70; item1_price_value0 = 0; item1_price_value1 = 0; item1_price_value2 = 0; item1_price_value3 = 0; item1_price_value4 = 0; item1_calories_value0 = 0; item1_calories_value1 = 0; item1_calories_value2 = 0; item1_calories_value3 = 0; item1_calories_value4 = 0; item1_fatrate_value0 = 0; item1_fatrate_value1 = 0; item1_fatrate_value2 = 0; item1_fatrate_value3 = 0; item1_fatrate_value4 = 0; // ITEM 2: RAMEN item2_price[0] = 1.99; item2_price[1] = 2.99; item2_price[2] = 2.49; item2_price[3] = 2.49; item2_price[4] = 2.49; item2_calories[0] = 200; item2_calories[1] = 900; item2_calories[2] = 378; item2_calories[3] = 378; item2_calories[4] = 378; item2_fatrate[0] = 20; item2_fatrate[1] = 14; item2_fatrate[2] = 40; item2_fatrate[3] = 40; item2_fatrate[4] = 40; item2_price_value0 = 0; item2_price_value1 = 0; item2_price_value2 = 0; item2_price_value3 = 0; item2_price_value4 = 0; item2_calories_value0 = 0; item2_calories_value1 = 0; item2_calories_value2 = 0; item2_calories_value3 = 0; item2_calories_value4 = 0; item2_fatrate_value0 = 0; item2_fatrate_value1 = 0; item2_fatrate_value2 = 0; item2_fatrate_value3 = 0; item2_fatrate_value4 = 0; /////////////////////////////////////////////// // colors color0.set(205,26,38); color1.set(101,16,40); color2.set(205,18,74); color3.set(234,144,146); color4.set(20,137,68); }
// --------------------------------------------------------------------------------------------------------------------------------------------------- // void CommonTimeBase::baseInit() { ofAddListener(ofEvents().update, this, &CommonTimeBase::_update ); }
void ofxTLVideoTrack::setup(){ ofxTLImageTrack::setup(); isSetup = true; ofAddListener(ofEvents().exit, this, &ofxTLVideoTrack::exit); startThread(); }
void ofxMSAInteractiveObject::enableDrawEvents() { ofAddListener(ofEvents.draw, this, &ofxMSAInteractiveObject::_draw); }
void audioVisualApp::setup() { ofSetVerticalSync(true); plotHeight = 700; bufferSize = 2048; fft = ofxFft::create(bufferSize, OF_FFT_WINDOW_HAMMING); // To use FFTW, try: //fft = ofxFft::create(bufferSize, OF_FFT_WINDOW_HAMMING, OF_FFT_FFTW); drawBins.resize(fft->getBinSize()); middleBins.resize(fft->getBinSize()); audioBins.resize(fft->getBinSize()); // 0 output channels, // 1 input channel // 44100 samples per second // [bins] samples per buffer // 4 num buffers (latency) soundPlayer = new ofSoundPlayer(); soundPlayer->load("sounds/Lecture1.wav"); // soundPlayer->play(); soundPlayer->setLoop(OF_LOOP_NORMAL); soundPlayer->setVolume(1.0); settings.add(sampleHeight.set("Sample Height", sampleImage.getHeight()/2, 0, sampleImage.getHeight())); settings.add(outputOn.set("Output On", false)); settings.add(play.set("Play!", false)); settings.add(exposure.set("Exposure (sec)", 300, 1, 600)); gui.setup("settings/settings.xml"); gui.add(settings); ofxNestedFileLoader loader; vector<string> soundPaths = loader.load("sounds"); for(int i = 0; i < soundPaths.size(); i++) { vector<string> tempPath = ofSplitString(soundPaths[i], "/"); string nameWithExtension = tempPath[tempPath.size()-1]; vector<string> tempName = ofSplitString(nameWithExtension, "."); if(tempName.size() == 2) { ofParameter<bool>* clip; clip = new ofParameter<bool>; clip->set(tempName[0], false); soundClips[tempName[0]] = soundPaths[i]; clips.add(*clip); } else { ofLogError("Your File name had a '.' in it which is weird..., skipping file: " + nameWithExtension); } } gui.add(clips); drawGui = true; ofAddListener(clips.parameterChangedE(), this, &audioVisualApp::onClipChanged); ofAddListener(settings.parameterChangedE(), this, &audioVisualApp::onSettingChanged); ofSoundStreamSetup(0, 1, this, 44100, bufferSize, 4); ofBackground(0, 0, 0); ofSetBackgroundAuto(false); ofSetLineWidth(2); }
void ofxMSAInteractiveObject::enableKeyEvents() { ofAddListener(ofEvents.keyPressed, this, &ofxMSAInteractiveObject::_keyPressed); ofAddListener(ofEvents.keyReleased, this, &ofxMSAInteractiveObject::_keyReleased); }
soundMap::soundMap() { midiOut.listPorts(); midiOut.openPort(0); //svgPaths.load("flrPlnDistortededitted5.svg"); svgPaths.load("flrPlnDistortededitted5copy.svg"); room =9; // ofLog()<<room; if(room==2) { // 37 tracks per channel // 592 // we could have up to 74 audio files. //midiOut.sendNoteOn(9, 1, 30); //midiOut.sendNoteOn(9, 1, 127); //midiOut.se //midiOut.sendControlChange(9,85,0); //midiOut.sendControlChange(8,85,127); } timeline.setup(); //registers events timeline.setDurationInSeconds(500); //sets time timeline.setLoopType(OF_LOOP_NORMAL); //turns the timeline to loop ofVec2f point; point.set( 0, 580 ); timeline.setOffset(point); timeline.addFlags("temporalAudioMarkers"); ofAddListener(timeline.events().bangFired, this, &soundMap::receivedBang); // turn everything off - so nothing is weird //midiOut.sendNoteOn(2, 50,50); ofLog()<< "nn"; midiOut.sendNoteOn(1, 50,50); midiOut.sendNoteOn(1, 48,50); midiOut.sendNoteOn(1, 49,50); midiOut.sendNoteOn(1, 51,50); midiOut.sendNoteOn(1, 44,50); midiOut.sendNoteOn(1, 45,50); midiOut.sendNoteOn(1, 46,50); midiOut.sendNoteOn(1, 47,50); midiOut.sendNoteOn(1, 40,50); midiOut.sendNoteOn(1, 41,50); midiOut.sendNoteOn(1, 43,50); //midiOut.sendNoteOn(1,42,50); //midiOut.sendControlChange(1,22,2.5); // play sound depending on which room convesation.posX= 150; convesation.posY= 150; convesation.spreadFactor = 30; convesation.width = 10; convesation.HighestVolume = 100; convesation.toAnimate = "PathTest.xml"; clock.posX = 481; clock.posY = 244; clock.spreadFactor = 20; clock.width = 40; clock.HighestVolume = 20; clock.clipToRoom = 1; clock.muffleFactor = .5; clock.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); showerDrip.posX = 525; showerDrip.posY = 105; showerDrip.spreadFactor = 18; showerDrip.width = 30; showerDrip.clipToRoom =2; showerDrip.muffleFactor =.4; showerDrip.HighestVolume = 30; showerDrip.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); kitchenClock.posX = 588; kitchenClock.posY = 212; kitchenClock.spreadFactor = 30; kitchenClock.width =40; kitchenClock.clipToRoom =3; kitchenClock.muffleFactor =.6; kitchenClock.HighestVolume = 50; kitchenClock.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); fridge.posX = 468; fridge.posY = 182; fridge.spreadFactor = 4; fridge.width =80; fridge.clipToRoom =3; fridge.muffleFactor =.8; fridge.HighestVolume = 40; fridge.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); windowBack.posX = 658; windowBack.posY = 553; windowBack.spreadFactor = 15; windowBack.width =5; windowBack.clipToRoom =3; windowBack.muffleFactor =.8; windowBack.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); windowFront.posX = 0; windowFront.posY = 389; windowFront.spreadFactor = 20; windowFront.width =40; windowFront.clipToRoom = 1; windowFront.muffleFactor = .5; windowFront.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); theRattle.posX = 136; theRattle.posY = 108; theRattle.spreadFactor= 3; theRattle.width = 20; theRattle.clipToRoom = 1; theRattle.muffleFactor =.4; theRattle.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); theRattle.duration = 22; theRattle.timePast = -1; theRattle.goTime = false; catPurring.posX = 163; catPurring.posY = 131; catPurring.spreadFactor= 7; catPurring.width = 30; catPurring.clipToRoom = 1; catPurring.muffleFactor =.4; catPurring.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); catPurring.duration = 13; catPurring.timePast = -1; catPurring.goTime = false; skinScratch.posX = 277; skinScratch.posY = 116; skinScratch.spreadFactor= 17; skinScratch.width = 40; skinScratch.clipToRoom = 1; skinScratch.muffleFactor =.4; skinScratch.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); skinScratch.duration = 24; skinScratch.HighestVolume =80; skinScratch.timePast = -1; skinScratch.goTime = false; writing.posX = 306; writing.posY = 497; writing.spreadFactor= 30; writing.width = 20; writing.clipToRoom = 1; writing.muffleFactor =.4; writing.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); writing.duration = 243; writing.timePast = -1; writing.goTime = false; crying.posX = 277; crying.posY = 116; crying.spreadFactor= 40; crying.width = 20; crying.clipToRoom = 1; crying.muffleFactor =.5; crying.HighestVolume = 60; crying.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); crying.duration = 22; crying.timePast = -1; crying.goTime = false; showerTime.posX = 712; showerTime.posY = 153; showerTime.spreadFactor= 70; showerTime.width = 20; showerTime.clipToRoom = 2; showerTime.muffleFactor =.4; showerTime.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); showerTime.duration = 733; showerTime.timePast = -1; showerTime.HighestVolume = 50; showerTime.goTime = false; tubDrip.posX = 712; tubDrip.posY = 153; tubDrip.spreadFactor= 13; tubDrip.width = 20; tubDrip.clipToRoom = 2; tubDrip.muffleFactor =.4; tubDrip.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); tubDrip.duration = 25; tubDrip.timePast = -1; tubDrip.goTime = false; mixing.posX = 630; mixing.posY = 502; mixing.spreadFactor= 35; mixing.width = 20; mixing.clipToRoom = 3; mixing.muffleFactor =.4; mixing.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); mixing.duration = 36; mixing.timePast = -1; mixing.goTime = false; stove.posX = 532; stove.posY = 285; stove.spreadFactor= 15; stove.width = 30; stove.clipToRoom = 3; stove.muffleFactor =.4; stove.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); stove.duration = 69; stove.timePast = -1; stove.goTime = false; eggCrack.posX = 620; eggCrack.posY = 489; eggCrack.spreadFactor= 30 ; eggCrack.width = 40; eggCrack.clipToRoom = 3; eggCrack.muffleFactor =.4; eggCrack.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); eggCrack.duration = 24; eggCrack.timePast = -1; eggCrack.goTime = false; appleChop.posX = 607; appleChop.posY = 493; appleChop.spreadFactor= 40; appleChop.width = 20; appleChop.clipToRoom = 3; appleChop.muffleFactor =.4; appleChop.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); appleChop.duration = 79; appleChop.timePast = -1; appleChop.goTime = false; //livingRoom mug mug1.posX = 247; mug1.posY = 492; mug1.spreadFactor= 10; mug1.width = 40; mug1.clipToRoom = 1; mug1.muffleFactor =.4; mug1.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); mug1.duration = 1; mug1.timePast = -1; mug1.goTime = false; //kitchen mug mug2.posX = 623; mug2.posY = 497; mug2.spreadFactor= 7; mug2.width = 20; mug2.clipToRoom = 3; mug2.muffleFactor =.4; mug2.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); mug2.duration = 7; mug2.timePast = -1; mug2.goTime = false; waterPour.posX =253; waterPour.posY = 510; waterPour.spreadFactor= 80; waterPour.width = 20; waterPour.clipToRoom = 1; waterPour.muffleFactor =.4; waterPour.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); waterPour.duration = 8; waterPour.timePast = -1; waterPour.goTime = false; kettle.posX = 553; kettle.posY = 301; kettle.spreadFactor= 30; kettle.width = 20; kettle.clipToRoom = 2; kettle.muffleFactor =.4; kettle.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); kettle.duration = 22; kettle.timePast = -1; kettle.goTime = false; brushTeeth.posX = 583; brushTeeth.posY = 105; brushTeeth.spreadFactor= 50; brushTeeth.width = 20; brushTeeth.clipToRoom = 2; brushTeeth.muffleFactor =.4; brushTeeth.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); brushTeeth.duration = 22; brushTeeth.timePast = -1; brushTeeth.goTime = false; longCooking.posX = 472; longCooking.posY = 275; longCooking.spreadFactor= 20; longCooking.width = 30; longCooking.clipToRoom = 3; longCooking.HighestVolume = 30; longCooking.muffleFactor =.65; longCooking.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); longCooking.duration = 537; longCooking.timePast = -1; longCooking.goTime = false; humming.posX = 270; humming.posY = 430; humming.spreadFactor= 70; humming.width = 50; humming.clipToRoom = 1; humming.muffleFactor =.7; humming.HighestVolume = 50; humming.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); humming.duration = 53; humming.timePast = -1; humming.goTime = false; gwenRun.posX = 235; gwenRun.posY = 285; gwenRun.spreadFactor= 50; gwenRun.width = 40; gwenRun.clipToRoom = 1; gwenRun.muffleFactor =.5; gwenRun.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); gwenRun.duration = 4; gwenRun.timePast = -1; gwenRun.goTime = false; overheardUpstairs.posX = 686; overheardUpstairs.posY = 431; overheardUpstairs.spreadFactor= 15; overheardUpstairs.width = 20; overheardUpstairs.clipToRoom = 3; overheardUpstairs.muffleFactor =.9; overheardUpstairs.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); overheardUpstairs.duration = 76; overheardUpstairs.timePast = -1; overheardUpstairs.goTime = false; dishes.posX = 530; dishes.posY = 376; dishes.spreadFactor= 30; dishes.width = 20; dishes.clipToRoom = 3; dishes.muffleFactor =.4; dishes.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); dishes.duration = 1352; dishes.timePast = -1; dishes.HighestVolume = 60; dishes.goTime = false; sleep.posX = 298; sleep.posY = 205; sleep.spreadFactor= 15; sleep.width = 20; sleep.clipToRoom = 1; sleep.muffleFactor =.4; sleep.color = ofColor((int)ofRandom(219,249),(int)ofRandom(187,217),(int)ofRandom(187,217)); sleep.duration = 86; sleep.timePast = -1; sleep.goTime = false; int controlNums[28] = {22,23,24,25,26,27,28,29,105,106,107,108,90,102,103,104,86, 87,88,89,31,85,109,110,111,113,114,112}; for(int i=0; i< 28; i++ ) { midiOut.sendControlChange(1,controlNums[i],100); midiOut.sendControlChange(1,controlNums[i],127); midiOut.sendControlChange(1,controlNums[i],0); ofLog()<<"hry"; } }
//-------------------------------------------------------------- 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(); /* */ }
//-------------------------------------------------------------- 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); }