From 64c89ab53447a004002ec0b0db94fd0a1e632cf6 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 28 Jan 2018 22:20:49 +0000 Subject: POC driver --- drawing/src/colourPolyline.cpp | 21 -------- drawing/src/colourPolyline.h | 18 ------- drawing/src/ofApp.cpp | 117 +++++++++++++++++++++++++++++++++++++---- drawing/src/ofApp.h | 10 ++++ 4 files changed, 118 insertions(+), 48 deletions(-) delete mode 100644 drawing/src/colourPolyline.cpp delete mode 100644 drawing/src/colourPolyline.h (limited to 'drawing') 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 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 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;igetSegments(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 shapes; for (int i = 0; i < contourFinder.nBlobs; i++){ @@ -281,9 +356,9 @@ void ofApp::draw(){ std::stringstream strm; strm << "mode: " << mode << " segments: "< 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; }; -- cgit v1.2.3