From ba37049c44ff64b3c6482a5e2f199f178351a69f Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 29 Jan 2013 01:52:00 +0000 Subject: mostly working --- addons.make | 2 +- bin/data/settings.xml | 61 +++++++++++++++++++---- figgis_detect.layout | 26 +++++----- src/boundary.cpp | 32 ++++++++++-- src/boundary.h | 27 +++++----- src/testApp.cpp | 134 +++++++++++++++++++++++++++++--------------------- src/testApp.h | 55 +++++++++++++++------ 7 files changed, 227 insertions(+), 110 deletions(-) diff --git a/addons.make b/addons.make index 4ad9634..68f9186 100644 --- a/addons.make +++ b/addons.make @@ -1,4 +1,4 @@ ofxOpenCv ofxXmlSettings -ofxOsc ofxFenster +ofxGui diff --git a/bin/data/settings.xml b/bin/data/settings.xml index cc22eb8..b18ba0c 100755 --- a/bin/data/settings.xml +++ b/bin/data/settings.xml @@ -1,14 +1,7 @@ - + - - - - - - - - + @@ -16,11 +9,59 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figgis_detect.layout b/figgis_detect.layout index 0e77965..ec2556a 100644 --- a/figgis_detect.layout +++ b/figgis_detect.layout @@ -2,27 +2,27 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/src/boundary.cpp b/src/boundary.cpp index 64957ed..2425c4a 100755 --- a/src/boundary.cpp +++ b/src/boundary.cpp @@ -5,9 +5,10 @@ boundary::boundary() filename=""; } -boundary::boundary(string file) +boundary::boundary(string file,float vol) { - filename=file; + openFile(file); + sound.setVolume(vol); } boundary::~boundary() @@ -77,7 +78,28 @@ bool boundary::contains(ofPoint p) else return true; } - -void boundary::checkfile(ofPoint pos,string file) { - if (contains(pos)) filename=file; +void boundary::openFile(string file) { + filename=file; + if (filename.length()>0) { + if (sound.loadSound(filename)) sound.setLoop(false); + else printf("failed to load %s\n",filename.c_str()); + } +} +bool boundary::checkFile(ofPoint pos,string file) { + if (contains(pos)) { + sound.stop(); + openFile(file); + return true; + } + else return false; +} +bool boundary::checkClick(ofPoint pos){ + if (contains(pos)&&sound.isLoaded()&&!sound.getIsPlaying()) { + sound.play(); + return true; + } + else return false; } +void boundary::setVolume(float vol){ + sound.setVolume(vol); +} diff --git a/src/boundary.h b/src/boundary.h index e28b278..bf0b780 100755 --- a/src/boundary.h +++ b/src/boundary.h @@ -9,19 +9,22 @@ class boundary { public: boundary(); - boundary(string file); + boundary(string file,float vol=1.0f); virtual ~boundary(); - bool contains(ofPoint p); - void draw(); - void add(ofPoint p); - void undo(); - void getCentroid(); - vector points; - ofPoint centroid; - - void checkfile(ofPoint pos,string file); - - string filename; + bool contains(ofPoint p); + void draw(); + void add(ofPoint p); + void undo(); + void getCentroid(); + vector points; + ofPoint centroid; + bool checkClick(ofPoint pos); + bool checkFile(ofPoint pos,string file); + void openFile(string file); + void setVolume(float vol); + + string filename; + ofSoundPlayer sound; }; diff --git a/src/testApp.cpp b/src/testApp.cpp index 1ca45e4..0392c92 100755 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -1,19 +1,24 @@ #include "testApp.h" //-------------------------------------------------------------- +guiWindow::~guiWindow(){ + cout << "gui window destroyed" << endl; +} +void guiWindow::setup(){} +void guiWindow::setParent(testApp *p){ + parent=p; +} +void guiWindow::draw(){ + parent->gui.draw(); +} +//-------------------------------------------------------------- void testApp::setup(){ loadSettings("settings.xml"); - //sender.setup(host.c_str(),port); - sender.setup("169.254.113.20",57117); - - bInvert=true; - threshold = 80; - // gw=720; gh=576; vidGrabber.setVerbose(true); - bool bGrab=false; + bGrab=false; //vidGrabber.initGrabber(gw,gh); //base grab size colorImg.allocate(gw,gh); @@ -25,33 +30,35 @@ void testApp::setup(){ bLearnBakground = true; - - bFlip=true; - if (boundaries.size()==0) { boundaries.push_back(boundary()); } selectedBoundary=0; -// ofAddListener(ofEvents().fileDragEvent, this, &testApp::fileDragEvent); - /* guiWin=new guiWindow(); - //gui window stuff - ofxFenster* win2=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW); + ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 200, 200, OF_WINDOW); //ofAddListener(win2->events.windowResized, this, &testApp::windowEvent); - win2->setWindowTitle("config"); - win2->addListener(guiWin); + //volume is set in loadSettings + gui.setup("","panel.xml",0,0); + gui.add(vol.setup("volume",volume,0,1.0,255)); + vol.addListener(this,&testApp::volumeChanged); + gui.add(bFlip.setup("flip grab", flip)); + gui.add(bInvert.setup("invert grab", invert)); + gui.add(thresh.setup("threshold",threshold,0,255,255)); + win->setWindowTitle("config"); + win->addListener(guiWin); guiWin->setup(); guiWin->setParent(this); -*/ + } //-------------------------------------------------------------- void testApp::update(){ - if (bGrab) { vidGrabber.grabFrame(); + if (bGrab) { + vidGrabber.grabFrame(); bool bNewFrame = vidGrabber.isFrameNew(); if (bNewFrame){ colorImg.setFromPixels(vidGrabber.getPixels(), gw,gh); @@ -67,34 +74,35 @@ void testApp::update(){ contourFinder.findContours(grayDiff, 20, (gw*gh)/3, 10, true); // find holes } - //generate midi -/* + //generate events + for (int i = 0; i < contourFinder.nBlobs; i++){ for (int j=0;j volume; + ofxToggle bFlip; + ofxToggle bInvert; + ofxIntSlider thresh; + ofxParameter threshold; + + // register any method of any class to an event. + // the method must provide one of the following + // signatures: + // void method(ArgumentsType & args) + // void method(const void * sender, ArgumentsType &args) + // ie: + // ofAddListener(addon.newIntEvent, this, &Class::method) + void volumeChanged(float &v); + + bool bGrab; vector boundaries; int selectedBoundary; + vector clicks; +}; + +class guiWindow: public ofxFensterListener{ +public: + ~guiWindow(); + testApp *parent; + void setup(); + void setParent(testApp *p); + void draw(); }; + -- cgit v1.2.3