diff options
Diffstat (limited to 'drawing')
| -rw-r--r-- | drawing/src/colourPolyline.cpp | 21 | ||||
| -rw-r--r-- | drawing/src/colourPolyline.h | 18 | ||||
| -rw-r--r-- | drawing/src/ofApp.cpp | 117 | ||||
| -rw-r--r-- | drawing/src/ofApp.h | 10 |
4 files changed, 118 insertions, 48 deletions
diff --git a/drawing/src/colourPolyline.cpp b/drawing/src/colourPolyline.cpp deleted file mode 100644 index 810488d..0000000 --- a/drawing/src/colourPolyline.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "colourPolyline.h" - -void colourPolyline::addVertex( const ofPoint& p , const ofColor& c){ - ofPolyline::addVertex( p ); - pointColours.push_back( c ); -} - -void colourPolyline::addVertex( const ofPoint& p ){ - addVertex( p , ofColor(255,255,255)); -} - -void colourPolyline::draw(){ - for (int i=0;i<ofPolyline::size()-1;i++){ - ofSetColor(pointColours[i]); - ofPolyline l; - l.addVertex(ofPolyline::operator[](i)); - l.addVertex(ofPolyline::operator[](i+1)); - l.draw(); - //todo - cache - } -} diff --git a/drawing/src/colourPolyline.h b/drawing/src/colourPolyline.h deleted file mode 100644 index 2dc3872..0000000 --- a/drawing/src/colourPolyline.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "ofPolyline.h" -#include "ofMain.h" - -class colourPolyline: public ofPolyline { - public: - - void addVertex( const ofPoint& p ); - - void addVertex( const ofPoint& p , const ofColor& c); - - void draw(); - - private: - - vector <ofColor> pointColours; - -};
\ No newline at end of file diff --git a/drawing/src/ofApp.cpp b/drawing/src/ofApp.cpp index d110414..9376723 100644 --- a/drawing/src/ofApp.cpp +++ b/drawing/src/ofApp.cpp @@ -7,7 +7,7 @@ vector<std::string> cmdnames={"moveTo","lineTo","curveTo","bezierTo","quadBezier //-------------------------------------------------------------- void ofApp::setup(){ ofxSVG svg; - svg.load("bars.svg"); + svg.load("haring.svg"); imagepaths= svg.getPaths(); for (int i=0;i<imagepaths.size();i++){ @@ -59,6 +59,46 @@ void ofApp::setup(){ movie.play(); threshold=128; + + //setup our directory + dir.setup(); + //setup our client + client.setup(); + + syphonFbo.allocate(800,600); + + //register for our directory's callbacks + ofAddListener(dir.events.serverAnnounced, this, &ofApp::serverAnnounced); + // not yet implemented + //ofAddListener(dir.events.serverUpdated, this, &ofApp::serverUpdated); + ofAddListener(dir.events.serverRetired, this, &ofApp::serverRetired); + + dirIdx = -1; +} + +//these are our directory's callbacks +void ofApp::serverAnnounced(ofxSyphonServerDirectoryEventArgs &arg) +{ + for( auto& dir : arg.servers ){ + ofLogNotice("ofxSyphonServerDirectory Server Announced")<<" Server Name: "<<dir.serverName <<" | App Name: "<<dir.appName; + } + dirIdx = 0; +} + +void ofApp::serverUpdated(ofxSyphonServerDirectoryEventArgs &arg) +{ + for( auto& dir : arg.servers ){ + ofLogNotice("ofxSyphonServerDirectory Server Updated")<<" Server Name: "<<dir.serverName <<" | App Name: "<<dir.appName; + } + dirIdx = 0; +} + +void ofApp::serverRetired(ofxSyphonServerDirectoryEventArgs &arg) +{ + for( auto& dir : arg.servers ){ + ofLogNotice("ofxSyphonServerDirectory Server Retired")<<" Server Name: "<<dir.serverName <<" | App Name: "<<dir.appName; + } + dirIdx = 0; } //-------------------------------------------------------------- @@ -96,7 +136,7 @@ void ofApp::draw(){ //transform points of segmenter before intersecting with mask switch (mode){ - case 0:{ + case 7:{ for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){ auto segments=shape->getSegments(numsegments,coverage,phase); for (auto segment=segments.begin();segment!=segments.end();segment++){ @@ -239,14 +279,49 @@ void ofApp::draw(){ break; } - case 7: { - movie.update(); - ofPoint scale=ofPoint(ofGetWidth()/movie.getWidth(),ofGetHeight()/movie.getHeight()); - if (movie.isFrameNew()){ - colorImg.setFromPixels(movie.getPixels()); + case 0: { + ofPoint scale; + if(dir.isValidIndex(dirIdx)){ + //client.update(); + /* + scale=ofPoint(ofGetWidth()/client.getWidth(),ofGetHeight()/client.getHeight()); + ofPixels pixels; + ofTexture texture=client.getTexture(); + texture.bind(); + texture.readToPixels(pixels); + texture.unbind(); + colorImg.setFromPixels(pixels); grayImage = colorImg; grayImage.threshold(threshold); contourFinder.findContours(grayImage, 20, (340*240)/3, 10, true); + */ + scale=ofPoint(ofGetWidth()/syphonFbo.getWidth(),ofGetHeight()/syphonFbo.getHeight()); + + syphonFbo.begin(); + client.draw(0, 0, syphonFbo.getWidth(),syphonFbo.getHeight()); + syphonFbo.end(); + //syphonFbo.draw(0,0,ofGetWidth(),ofGetHeight()); //works + //printf("got fbo: %ix%i format %i\n",syphonFbo.getWidth(),syphonFbo.getHeight(),syphonFbo.getTexture().getPixelFormat()); + //syphonFbo.updateTexture(0); + ofPixels pixels; + syphonFbo.getTexture().readToPixels(pixels); + //printf("got texture: %ix%i format %i\n",pixels.getWidth(),pixels.getHeight(),pixels.getPixelFormat()); + //pixels are in RGBA format allegedly, but maybe this is the problem + colorImg.setFromPixels(pixels); + colorImg.draw(0,0,ofGetWidth(),ofGetHeight()); //mangled + grayImage = colorImg; + grayImage.threshold(threshold); + contourFinder.findContours(grayImage, 20, (340*240)/3, 10, true); + } + else { + movie.update(); + scale=ofPoint(ofGetWidth()/movie.getWidth(),ofGetHeight()/movie.getHeight()); + if (movie.isFrameNew()){ + colorImg.setFromPixels(movie.getPixels()); + grayImage = colorImg; + grayImage.threshold(threshold); + contourFinder.findContours(grayImage, 20, (340*240)/3, 10, true); + } } vector <colourPolyline> shapes; for (int i = 0; i < contourFinder.nBlobs; i++){ @@ -281,9 +356,9 @@ void ofApp::draw(){ std::stringstream strm; strm << "mode: " << mode << " segments: "<<segmentsdrawn<< " points: "<<pointsdrawn; - ofSetWindowTitle(strm.str()); + //ofSetWindowTitle(strm.str()); - mainOutputSyphonServer.publishScreen(); + //mainOutputSyphonServer.publishScreen(); } @@ -335,6 +410,30 @@ void ofApp::keyReleased(int key){ threshold=min(threshold+1,255); break; } + case ' ':{ + if (dir.size() > 0) + { + dirIdx++; + if(dirIdx > dir.size() - 1) + dirIdx = 0; + + client.set(dir.getDescription(dirIdx)); + string serverName = client.getServerName(); + string appName = client.getApplicationName(); + + if(serverName == ""){ + serverName = "null"; + } + if(appName == ""){ + appName = "null"; + } + ofSetWindowTitle(serverName + ":" + appName); + } + else + { + ofSetWindowTitle("No Server"); + } + } } } diff --git a/drawing/src/ofApp.h b/drawing/src/ofApp.h index 1667334..d1674c7 100644 --- a/drawing/src/ofApp.h +++ b/drawing/src/ofApp.h @@ -61,4 +61,14 @@ class ofApp : public ofBaseApp{ ofxCvContourFinder contourFinder; int threshold; + + void serverAnnounced(ofxSyphonServerDirectoryEventArgs &arg); + void serverUpdated(ofxSyphonServerDirectoryEventArgs &args); + void serverRetired(ofxSyphonServerDirectoryEventArgs &arg); + + ofxSyphonServerDirectory dir; + ofxSyphonClient client; + int dirIdx; + + ofFbo syphonFbo; }; |
