summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons.make1
-rwxr-xr-xbin/data/settings.xml42
-rwxr-xr-xfiggis_detect.cbp3
-rw-r--r--figgis_detect.layout23
-rwxr-xr-xsrc/boundary.cpp12
-rwxr-xr-xsrc/boundary.h6
-rwxr-xr-xsrc/main.cpp4
-rwxr-xr-xsrc/testApp.cpp125
-rwxr-xr-xsrc/testApp.h30
9 files changed, 149 insertions, 97 deletions
diff --git a/addons.make b/addons.make
index b09bf70..4ad9634 100644
--- a/addons.make
+++ b/addons.make
@@ -1,3 +1,4 @@
ofxOpenCv
ofxXmlSettings
ofxOsc
+ofxFenster
diff --git a/bin/data/settings.xml b/bin/data/settings.xml
index 6c1f067..cc22eb8 100755
--- a/bin/data/settings.xml
+++ b/bin/data/settings.xml
@@ -1,28 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<figgis host="192.168.15.6" port="57117" channel="1" threshold="80" invert="1" />
+<figgis host="169.254.113.20" port="57117" channel="1" threshold="80" invert="1" />
<boundaries>
- <boundary note="43">
- <point x="204.000000" y="50.000000"></point>
- <point x="32.000000" y="27.000000"></point>
- <point x="25.000000" y="208.000000"></point>
- <point x="122.000000" y="313.000000"></point>
- <point x="204.000000" y="129.000000"></point>
+ <boundary filename="five.wav">
+ <point x="224.000000" y="79.000000"></point>
+ <point x="281.000000" y="253.000000"></point>
+ <point x="286.000000" y="421.000000"></point>
+ <point x="86.000000" y="395.000000"></point>
+ <point x="49.000000" y="94.000000"></point>
</boundary>
- <boundary note="40">
- <point x="598.000000" y="19.000000"></point>
- <point x="504.000000" y="25.000000"></point>
- <point x="505.000000" y="167.000000"></point>
- <point x="540.000000" y="287.000000"></point>
- <point x="610.000000" y="259.000000"></point>
- <point x="618.000000" y="83.000000"></point>
+ <boundary filename="four.wav">
+ <point x="645.000000" y="40.000000"></point>
+ <point x="414.000000" y="53.000000"></point>
+ <point x="374.000000" y="150.000000"></point>
+ <point x="458.000000" y="239.000000"></point>
+ <point x="637.000000" y="224.000000"></point>
+ <point x="676.000000" y="157.000000"></point>
</boundary>
- <boundary note="43">
- <point x="36.000000" y="390.000000"></point>
- <point x="34.000000" y="460.000000"></point>
- <point x="623.000000" y="465.000000"></point>
- <point x="622.000000" y="411.000000"></point>
- <point x="497.000000" y="349.000000"></point>
- <point x="123.000000" y="340.000000"></point>
- <point x="32.000000" y="289.000000"></point>
+ <boundary filename="one.wav">
+ <point x="651.000000" y="343.000000"></point>
+ <point x="447.000000" y="361.000000"></point>
+ <point x="318.000000" y="536.000000"></point>
+ <point x="681.000000" y="536.000000"></point>
+ <point x="678.000000" y="401.000000"></point>
</boundary>
</boundaries>
diff --git a/figgis_detect.cbp b/figgis_detect.cbp
index 0c8e6b8..2fcb792 100755
--- a/figgis_detect.cbp
+++ b/figgis_detect.cbp
@@ -30,6 +30,9 @@
<Unit filename="addons.make">
<Option virtualFolder="build config/" />
</Unit>
+ <Unit filename="bin/data/settings.xml">
+ <Option virtualFolder="build config/" />
+ </Unit>
<Unit filename="config.make">
<Option virtualFolder="build config" />
</Unit>
diff --git a/figgis_detect.layout b/figgis_detect.layout
index 4d3d26b..0e77965 100644
--- a/figgis_detect.layout
+++ b/figgis_detect.layout
@@ -1,25 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
- <File name="addons.make" open="1" top="0" tabpos="4">
- <Cursor position="31" topLine="0" />
+ <File name="addons.make" open="0" top="0" tabpos="3">
+ <Cursor position="42" topLine="0" />
+ </File>
+ <File name="bin/data/settings.xml" open="1" top="0" tabpos="2">
+ <Cursor position="163" topLine="0" />
</File>
<File name="config.make" open="0" top="0" tabpos="1">
<Cursor position="376" topLine="18" />
</File>
- <File name="src/boundary.cpp" open="1" top="0" tabpos="2">
- <Cursor position="462" topLine="6" />
+ <File name="src/boundary.cpp" open="1" top="0" tabpos="3">
+ <Cursor position="1538" topLine="47" />
</File>
- <File name="src/boundary.h" open="1" top="0" tabpos="1">
+ <File name="src/boundary.h" open="0" top="0" tabpos="1">
<Cursor position="267" topLine="0" />
</File>
<File name="src/main.cpp" open="0" top="0" tabpos="0">
- <Cursor position="165" topLine="0" />
+ <Cursor position="430" topLine="0" />
</File>
- <File name="src/testApp.cpp" open="1" top="0" tabpos="3">
- <Cursor position="5345" topLine="190" />
+ <File name="src/testApp.cpp" open="1" top="1" tabpos="1">
+ <Cursor position="6071" topLine="201" />
</File>
- <File name="src/testApp.h" open="1" top="1" tabpos="5">
- <Cursor position="1069" topLine="31" />
+ <File name="src/testApp.h" open="0" top="0" tabpos="4">
+ <Cursor position="1313" topLine="0" />
</File>
</CodeBlocks_layout_file>
diff --git a/src/boundary.cpp b/src/boundary.cpp
index c30f676..64957ed 100755
--- a/src/boundary.cpp
+++ b/src/boundary.cpp
@@ -2,12 +2,12 @@
boundary::boundary()
{
- note=40; //middle C
+ filename="";
}
-boundary::boundary(int _note)
+boundary::boundary(string file)
{
- note=_note;
+ filename=file;
}
boundary::~boundary()
@@ -20,7 +20,7 @@ void boundary::draw(){
for (int i=0;i<points.size();i++) {
ofLine(points[i],points[(i+1)%points.size()]);
}
- ofDrawBitmapString(ofToString(note),centroid);
+ ofDrawBitmapString(filename,centroid);
}
}
@@ -77,3 +77,7 @@ bool boundary::contains(ofPoint p)
else
return true;
}
+
+void boundary::checkfile(ofPoint pos,string file) {
+ if (contains(pos)) filename=file;
+}
diff --git a/src/boundary.h b/src/boundary.h
index a4ee28b..e28b278 100755
--- a/src/boundary.h
+++ b/src/boundary.h
@@ -9,17 +9,19 @@ class boundary
{
public:
boundary();
- boundary(int _note);
+ boundary(string file);
virtual ~boundary();
bool contains(ofPoint p);
void draw();
void add(ofPoint p);
void undo();
- int note;
void getCentroid();
vector<ofPoint> points;
ofPoint centroid;
+
+ void checkfile(ofPoint pos,string file);
+ string filename;
};
diff --git a/src/main.cpp b/src/main.cpp
index e922099..fca2408 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,11 +6,11 @@
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(&window, 720,576, OF_WINDOW); // <-------- setup the GL context
+ ofSetupOpenGL(ofxFensterManager::get(), 720,576, OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
- ofRunApp( new testApp());
+ ofRunFensterApp( new testApp());
}
diff --git a/src/testApp.cpp b/src/testApp.cpp
index d093497..1ca45e4 100755
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -1,69 +1,85 @@
#include "testApp.h"
-
//--------------------------------------------------------------
void testApp::setup(){
loadSettings("settings.xml");
//sender.setup(host.c_str(),port);
- sender.setup("192.168.15.6",57117);
-
+ sender.setup("169.254.113.20",57117);
+
bInvert=true;
threshold = 80;
//
-
+
gw=720;
gh=576;
-
+
vidGrabber.setVerbose(true);
- vidGrabber.initGrabber(gw,gh); //base grab size
-
+ bool bGrab=false;
+ //vidGrabber.initGrabber(gw,gh); //base grab size
+
colorImg.allocate(gw,gh);
grayImage.allocate(gw,gh);
grayBg.allocate(gw,gh);
grayDiff.allocate(gw,gh);
-
+
mode=COLOUR;
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);
+
+ //ofAddListener(win2->events.windowResized, this, &testApp::windowEvent);
+
+ win2->setWindowTitle("config");
+ win2->addListener(guiWin);
+ guiWin->setup();
+ guiWin->setParent(this);
+
+*/
}
//--------------------------------------------------------------
void testApp::update(){
- vidGrabber.grabFrame();
- bool bNewFrame = vidGrabber.isFrameNew();
- if (bNewFrame){
- colorImg.setFromPixels(vidGrabber.getPixels(), gw,gh);
- if (bFlip) colorImg.mirror(false,true);
- grayImage = colorImg;
- if (bInvert) grayImage.invert();
- if (bLearnBakground == true){
- grayBg = grayImage; // the = sign copys the pixels from grayImage into grayBg (operator overloading)
- bLearnBakground = false;
- }
- grayDiff.absDiff(grayBg, grayImage);
- grayDiff.threshold(threshold);
- contourFinder.findContours(grayDiff, 20, (gw*gh)/3, 10, true); // find holes
- }
-
- //generate midi
-
- for (int i = 0; i < contourFinder.nBlobs; i++){
- for (int j=0;j<boundaries.size();j++) {
- if (boundaries[j].contains(contourFinder.blobs[i].centroid)) {
- sendNote(boundaries[j].note);
- //printf("sending %i\n",boundaries[j].note);
- }
- }
+ if (bGrab) { vidGrabber.grabFrame();
+ bool bNewFrame = vidGrabber.isFrameNew();
+ if (bNewFrame){
+ colorImg.setFromPixels(vidGrabber.getPixels(), gw,gh);
+ if (bFlip) colorImg.mirror(false,true);
+ grayImage = colorImg;
+ if (bInvert) grayImage.invert();
+ if (bLearnBakground == true){
+ grayBg = grayImage; // the = sign copys the pixels from grayImage into grayBg (operator overloading)
+ bLearnBakground = false;
+ }
+ grayDiff.absDiff(grayBg, grayImage);
+ grayDiff.threshold(threshold);
+ contourFinder.findContours(grayDiff, 20, (gw*gh)/3, 10, true); // find holes
+ }
+
+ //generate midi
+/*
+ for (int i = 0; i < contourFinder.nBlobs; i++){
+ for (int j=0;j<boundaries.size();j++) {
+ if (boundaries[j].contains(contourFinder.blobs[i].centroid)) {
+ sendNote(boundaries[j].note);
+ //printf("sending %i\n",boundaries[j].note);
+ }
+ }
+ }
+ */
}
-
+
}
//--------------------------------------------------------------
@@ -80,11 +96,11 @@ void testApp::draw(){
grayDiff.draw(0,0,gw,gh); //(ofGetHeight()-gh)/2,gw,ofGetHeight()+((gh-ofGetHeight())/2));
break;
}
-
+
for (int i = 0; i < contourFinder.nBlobs; i++){
contourFinder.blobs[i].draw(0,0); //(ofGetHeight()-gh)/2);
}
-
+
for (int i=0;i<boundaries.size();i++) {
if (selectedBoundary==i) ofSetColor(255,0,0);
else ofSetColor(180,0,0);
@@ -95,6 +111,12 @@ void testApp::draw(){
//--------------------------------------------------------------
void testApp::keyPressed(int key){
+ //make in fenster, drag/drop support
+ //drag sound file onto a sound area, its name becomes name of area
+ //keys to play/stop (test)
+ //overall sound level control
+ //fine tune image detection
+
switch (key){
case ' ':
bLearnBakground = true;
@@ -134,18 +156,20 @@ void testApp::keyPressed(int key){
case OF_KEY_PAGE_DOWN:
selectedBoundary=(selectedBoundary+1)%boundaries.size();
break;
+ /*
case OF_KEY_LEFT:
boundaries[selectedBoundary].note--;
break;
case OF_KEY_RIGHT:
boundaries[selectedBoundary].note++;
break;
+ */
case '1':
case '2':
case '3':
mode=key-48;
break;
-
+
}
}
@@ -158,6 +182,7 @@ void testApp::sendNote(int note){
m.addIntArg(127);
m.addIntArg(1);
sender.sendMessage(m);
+ //printf("sent %i\n",note);
}
//--------------------------------------------------------------
@@ -197,8 +222,18 @@ void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
-void testApp::dragEvent(ofDragInfo dragInfo){
-
+void testApp::dragEvent(ofDragInfo dragInfo, ofxFenster* win){
+ dragEvent(dragInfo);
+}
+void testApp::dragEvent(ofDragInfo dragInfo) {
+ printf("got draginfo: %f,%f,%f\n",dragInfo.position.x,dragInfo.position.y,dragInfo.position.z);
+ int sta=dragInfo.files[0].find_last_of("\\/")+1;
+ int len=(dragInfo.files[0].find_last_of(".")+4)-sta;
+ string filename=dragInfo.files[0].substr(sta,len);
+ printf("loading %s\n",filename.c_str());
+ for (int i=0;i<boundaries.size();i++) {
+ boundaries[i].checkfile(dragInfo.position,filename);
+ }
}
void testApp::loadSettings(string filename){
if( !XML.loadFile(filename) ){
@@ -211,7 +246,7 @@ void testApp::loadSettings(string filename){
threshold = XML.getAttribute("figgis","threshold",80,0);
if(XML.pushTag("boundaries")) {
for (int i=0;i<XML.getNumTags("boundary");i++){
- boundaries.push_back(boundary(XML.getAttribute("boundary","note",40,i)));
+ boundaries.push_back(boundary(XML.getAttribute("boundary","filename","",i)));
selectedBoundary=boundaries.size()-1;
XML.pushTag("boundary",i);
for (int j=0;j<XML.getNumTags("point");j++){
@@ -232,7 +267,7 @@ void testApp::saveSettings(string filename){
if(XML.pushTag("boundaries")) {
for (int i=0;i<boundaries.size();i++){
XML.addTag("boundary");
- XML.setAttribute("boundary","note",boundaries[i].note,i);
+ XML.setAttribute("boundary","filename",boundaries[i].filename,i);
if(XML.pushTag("boundary",i)) {
for (int j=0;j<boundaries[i].points.size();j++){
XML.addTag("point");
@@ -248,4 +283,4 @@ void testApp::saveSettings(string filename){
printf("saved %s\n",filename.c_str());
}
void testApp::exit(){
-} \ No newline at end of file
+}
diff --git a/src/testApp.h b/src/testApp.h
index 9bcf15e..e154493 100755
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -5,14 +5,18 @@
#include "boundary.h"
#include "ofxXmlSettings.h"
-
+#include "ofxFensterManager.h"
#include "ofxOsc.h"
#define COLOUR 1
#define GREY 2
#define DIFF 3
-class testApp : public ofBaseApp{
+//12-10-12
+//each area will trigger once and once only
+
+
+class testApp : public ofxFensterListener{
public:
void setup();
@@ -28,23 +32,24 @@ class testApp : public ofBaseApp{
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
+ void dragEvent(ofDragInfo dragInfo, ofxFenster* win);
void gotMessage(ofMessage msg);
-
+
ofxXmlSettings XML;
void loadSettings(string filename);
void saveSettings(string filename);
-
+
//destination for OSC
std::string host;
int port,channel;
ofxOscSender sender;
-
+
void sendNote(int note);
-
+
ofVideoGrabber vidGrabber;
-
+
int gw,gh;
-
+
ofxCvColorImage colorImg;
ofxCvGrayscaleImage grayImage;
@@ -52,16 +57,17 @@ class testApp : public ofBaseApp{
ofxCvGrayscaleImage grayDiff;
ofxCvContourFinder contourFinder;
-
+
int mode;
int threshold;
bool bLearnBakground;
-
+
+ bool bGrab;
bool bFlip;
bool bInvert;
-
+
vector<boundary> boundaries;
int selectedBoundary;
-
+
};