diff options
| author | Tim Redfern <tim@getdrop.com> | 2018-01-30 00:35:30 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2018-01-30 00:35:30 +0000 |
| commit | d60cc2aa2994f9e63d9570bea4fac8b8a9949b43 (patch) | |
| tree | bc333e74981e1a4bdae2bdc5faf31655033f653f /drawing | |
| parent | 512d5703e4e1affc1dc5dcd9f2892ac5944c666f (diff) | |
much progress
Diffstat (limited to 'drawing')
| -rw-r--r-- | drawing/addons.make | 3 | ||||
| -rw-r--r-- | drawing/src/main.cpp | 2 | ||||
| -rw-r--r-- | drawing/src/ofApp.cpp | 58 | ||||
| -rw-r--r-- | drawing/src/ofApp.h | 4 | ||||
| -rwxr-xr-x | drawing/start | 2 |
5 files changed, 48 insertions, 21 deletions
diff --git a/drawing/addons.make b/drawing/addons.make index 964322e..8ec4be6 100644 --- a/drawing/addons.make +++ b/drawing/addons.make @@ -1,4 +1,5 @@ ofxSvg ofxClipper ofxSyphon -ofxOpenCV
\ No newline at end of file +ofxOpenCV +ofxHelios
\ No newline at end of file diff --git a/drawing/src/main.cpp b/drawing/src/main.cpp index 50ef9f2..02b6b14 100644 --- a/drawing/src/main.cpp +++ b/drawing/src/main.cpp @@ -12,6 +12,8 @@ int main(int argc, char *argv[]){ settings.width = 1200; settings.height = 900; + //1200 = 13.2° = 42898 pts theoretical + shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings); shared_ptr<ofApp> mainApp(new ofApp); diff --git a/drawing/src/ofApp.cpp b/drawing/src/ofApp.cpp index 9376723..4b25356 100644 --- a/drawing/src/ofApp.cpp +++ b/drawing/src/ofApp.cpp @@ -1,23 +1,27 @@ #include "ofApp.h" #include "glew.h" +int MAX_POINTS=20000; +int LASER_INTENSITY=37; vector<std::string> cmdnames={"moveTo","lineTo","curveTo","bezierTo","quadBezierTo","arc","arcNegative","close"}; //-------------------------------------------------------------- void ofApp::setup(){ ofxSVG svg; - svg.load("haring.svg"); + svg.load("lorenzo.svg"); imagepaths= svg.getPaths(); - for (int i=0;i<imagepaths.size();i++){ - vector <ofPolyline> outlines= imagepaths[i].getOutline(); - for (int j=0;j<outlines.size();j++){ - segmenters.push_back(lineSegmenter(outlines[j])); + for (auto& path:imagepaths){ + path.setPolyWindingMode(OF_POLY_WINDING_ODD); + + vector <ofPolyline> outlines= path.getOutline(); + for (auto& outline:outlines){ + segmenters.push_back(lineSegmenter(outline)); } } - cout << "Drawing: found " << maskpaths.size() << " paths with " << segmenters.size() << " shapes" <<std::endl; + cout << "Drawing: found " << imagepaths.size() << " paths with " << segmenters.size() << " shapes" <<std::endl; svg.load("lorenzo.svg"); maskpaths= svg.getPaths(); @@ -48,11 +52,11 @@ void ofApp::setup(){ cout << "Mask: found " << maskpaths.size() << " paths with " << mask.size() << " shapes" <<std::endl; numsegments=1; - coverage=0.5; + coverage=0.1; mode=0; - ofSetFrameRate(30); + //ofSetFrameRate(30); movie.load("clouds_flythrough.mp4"); movie.setLoopState(OF_LOOP_NORMAL); @@ -74,6 +78,9 @@ void ofApp::setup(){ ofAddListener(dir.events.serverRetired, this, &ofApp::serverRetired); dirIdx = -1; + + laser.set_pts(MAX_POINTS); + laser.set_intensity(LASER_INTENSITY); } //these are our directory's callbacks @@ -129,20 +136,20 @@ void ofApp::draw(){ int segmentsdrawn=0; int pointsdrawn=0; - float phase=fmod(ofGetElapsedTimef()/2,1); + float phase=fmod(ofGetElapsedTimef()/10,1); //movie.draw(0,0,ofGetWidth(),ofGetHeight()); //transform points of segmenter before intersecting with mask + vector <colourPolyline> lasershapes; + switch (mode){ - case 7:{ + case 0:{ 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++){ - segment->draw(); - segmentsdrawn+=1; - pointsdrawn+=segment->size(); + lasershapes.push_back(colourPolyline(*segment)); } } break; @@ -279,7 +286,7 @@ void ofApp::draw(){ break; } - case 0: { + case 7: { ofPoint scale; if(dir.isValidIndex(dirIdx)){ //client.update(); @@ -303,12 +310,19 @@ void ofApp::draw(){ //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); + ofTexture texture= syphonFbo.getTexture(); + //texture.draw(0,0,ofGetWidth(),ofGetHeight()); //works + + //printf("got texture: %ix%i format %i\n",texture.getWidth(),texture.getHeight(),texture.getTextureData().glInternalFormat); + ofPixels pixels; - syphonFbo.getTexture().readToPixels(pixels); + texture.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); @@ -353,10 +367,18 @@ void ofApp::draw(){ for (auto& l:paths) l.draw(); */ + int num = laser.draw(lasershapes); - std::stringstream strm; - strm << "mode: " << mode << " segments: "<<segmentsdrawn<< " points: "<<pointsdrawn; - //ofSetWindowTitle(strm.str()); + for (auto& shape:lasershapes){ + shape.draw(); + } + + if (num>0){ + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)); + } + else { + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser error "); + } //mainOutputSyphonServer.publishScreen(); diff --git a/drawing/src/ofApp.h b/drawing/src/ofApp.h index d1674c7..13b3a0b 100644 --- a/drawing/src/ofApp.h +++ b/drawing/src/ofApp.h @@ -7,7 +7,7 @@ #include "ofxSyphon.h" #include "ofxOpenCv.h" -#include "colourPolyline.h" +#include "ofxHelios.h" class ofApp : public ofBaseApp{ @@ -71,4 +71,6 @@ class ofApp : public ofBaseApp{ int dirIdx; ofFbo syphonFbo; + + ofxHelios laser; }; diff --git a/drawing/start b/drawing/start index d80f5a8..d2bc74e 100755 --- a/drawing/start +++ b/drawing/start @@ -1,3 +1,3 @@ mkdir bin/drawing.app/Contents/Frameworks cp -r Frameworks/Syphon.framework bin/drawing.app/Contents/Frameworks - +cp libs/libHeliosDacAPI.dylib bin/drawing.app/Contents/MacOS/ |
