summaryrefslogtreecommitdiff
path: root/drawing/src/ofApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-01-22 23:28:16 +0000
committerTim Redfern <tim@getdrop.com>2018-01-22 23:28:16 +0000
commit60b2973637d6150f3facb74eb9ae1d475071b915 (patch)
tree45e4fe491e7067ed22f8597301aaf0c4c6f9b5b9 /drawing/src/ofApp.cpp
parentfa8fd80b285e8b916afa5b0424bcd00e579c0771 (diff)
thresholding
Diffstat (limited to 'drawing/src/ofApp.cpp')
-rw-r--r--drawing/src/ofApp.cpp55
1 files changed, 50 insertions, 5 deletions
diff --git a/drawing/src/ofApp.cpp b/drawing/src/ofApp.cpp
index 91daee1..8928df6 100644
--- a/drawing/src/ofApp.cpp
+++ b/drawing/src/ofApp.cpp
@@ -53,6 +53,12 @@ void ofApp::setup(){
mode=0;
ofSetFrameRate(30);
+
+ movie.load("clouds_flythrough.mp4");
+ movie.setLoopState(OF_LOOP_NORMAL);
+ movie.play();
+
+ threshold=128;
}
//--------------------------------------------------------------
@@ -61,6 +67,8 @@ void ofApp::update(){
clipper.Clear();
clipper.addPolylines(mask, ClipperLib::ptClip);
+
+
}
ofPolyline ofApp::polyLineTransform(const ofPolyline& poly, ofMatrix4x4 xform){
@@ -83,6 +91,8 @@ void ofApp::draw(){
float phase=fmod(ofGetElapsedTimef()/2,1);
+ //movie.draw(0,0,ofGetWidth(),ofGetHeight());
+
//transform points of segmenter before intersecting with mask
switch (mode){
@@ -163,7 +173,12 @@ void ofApp::draw(){
break;
}
case 5:{
- vector<ofPolyline> clipped = clipper.getOffsets(maskpaths,(phase*20)+1,true);
+ //the N only fucks up when the other shapes are drawn!
+ vector<ofPolyline> clipped;
+ for (auto & maskpath:maskpaths){
+ auto clips=clipper.getOffsets(maskpath,-((phase*20)+1),true);
+ clipped.insert(clipped.end(),clips.begin(),clips.end());
+ }
vector<ofPolyline> simplified = clipper.simplifyPolylines(clipped);
@@ -177,11 +192,12 @@ void ofApp::draw(){
pointsdrawn+=clip.size();
}
+/*
float phase1=fmod(phase+0.5f,1.0f);
clipped.clear();
- clipped = clipper.getOffsets(maskpaths,(phase1*20)+1,true);
+ clipped = clipper.getOffsets(maskpaths,-((phase*20)+1),true);
simplified.clear();
@@ -197,7 +213,7 @@ void ofApp::draw(){
pointsdrawn+=clip.size();
}
-
+*/
break;
}
case 6:{
@@ -223,7 +239,28 @@ void ofApp::draw(){
break;
}
- case 7:{
+ case 7: {
+ movie.update();
+ if (movie.isFrameNew()){
+ colorImg.setFromPixels(movie.getPixels());
+ grayImage = colorImg;
+ grayImage.threshold(threshold);
+ contourFinder.findContours(grayImage, 20, (340*240)/3, 10, true);
+ }
+ vector <ofPolyline> shapes;
+ for (int i = 0; i < contourFinder.nBlobs; i++){
+ ofPolyline shape;
+ for (auto& point:contourFinder.blobs[i].pts){
+ shape.addVertex(point);
+ }
+ shapes.push_back(shape);
+ segmentsdrawn++;
+ pointsdrawn+=shape.size();
+ contourFinder.blobs[i].draw(0,0);
+ }
+ break;
+ }
+ case 8:{
int w=ofRandom(1000);
segmenters[w%segmenters.size()].draw();
segmentsdrawn=1;
@@ -284,7 +321,15 @@ void ofApp::keyReleased(int key){
break;
}
case 'p':{
- mode=(mode+1)%8;
+ mode=(mode+1)%9;
+ break;
+ }
+ case '-':{
+ threshold=max(threshold-1,0);
+ break;
+ }
+ case '=':{
+ threshold=min(threshold+1,255);
break;
}
}