From d60cc2aa2994f9e63d9570bea4fac8b8a9949b43 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 30 Jan 2018 00:35:30 +0000 Subject: much progress --- drawing/addons.make | 3 ++- drawing/src/main.cpp | 2 ++ drawing/src/ofApp.cpp | 58 +++++++++++++++++++++++++++++++++++---------------- drawing/src/ofApp.h | 4 +++- drawing/start | 2 +- 5 files changed, 48 insertions(+), 21 deletions(-) (limited to 'drawing') 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 mainWindow = ofCreateWindow(settings); shared_ptr 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 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 outlines= imagepaths[i].getOutline(); - for (int j=0;j outlines= path.getOutline(); + for (auto& outline:outlines){ + segmenters.push_back(lineSegmenter(outline)); } } - cout << "Drawing: found " << maskpaths.size() << " paths with " << segmenters.size() << " shapes" < 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: "<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/ -- cgit v1.2.3