summaryrefslogtreecommitdiff
path: root/drawing/src
diff options
context:
space:
mode:
Diffstat (limited to 'drawing/src')
-rw-r--r--drawing/src/ofApp.cpp55
-rw-r--r--drawing/src/ofApp.h11
2 files changed, 61 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;
}
}
diff --git a/drawing/src/ofApp.h b/drawing/src/ofApp.h
index 4e8dc69..a6f03a6 100644
--- a/drawing/src/ofApp.h
+++ b/drawing/src/ofApp.h
@@ -5,6 +5,7 @@
#include "lineSegmenter.h"
#include "ofxClipper.h"
#include "ofxSyphon.h"
+#include "ofxOpenCv.h"
class ofApp : public ofBaseApp{
@@ -48,4 +49,14 @@ class ofApp : public ofBaseApp{
ofx::Clipper clipper;
ofxSyphonServer mainOutputSyphonServer;
+
+ ofVideoPlayer movie;
+
+ ofxCvColorImage colorImg;
+
+ ofxCvGrayscaleImage grayImage;
+
+ ofxCvContourFinder contourFinder;
+
+ int threshold;
};