summaryrefslogtreecommitdiff
path: root/drawing/src/ofApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-01-30 00:35:30 +0000
committerTim Redfern <tim@getdrop.com>2018-01-30 00:35:30 +0000
commitd60cc2aa2994f9e63d9570bea4fac8b8a9949b43 (patch)
treebc333e74981e1a4bdae2bdc5faf31655033f653f /drawing/src/ofApp.cpp
parent512d5703e4e1affc1dc5dcd9f2892ac5944c666f (diff)
much progress
Diffstat (limited to 'drawing/src/ofApp.cpp')
-rw-r--r--drawing/src/ofApp.cpp58
1 files changed, 40 insertions, 18 deletions
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();