Created
April 22, 2016 23:14
-
-
Save stephanschulz/5d2c4a322a54ab84e21198fc1f1fbef5 to your computer and use it in GitHub Desktop.
ofxcv multiple contour finders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
int main() { | |
ofSetupOpenGL(640, 480, OF_WINDOW); | |
ofRunApp(new ofApp()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
using namespace ofxCv; | |
using namespace cv; | |
void ofApp::setup() { | |
cam.setup(320, 240); | |
for(int i=0; i<MAX_CAMS;i++){ | |
imitate(img[i], cam); | |
contourFinder[i].setMinAreaRadius(10); | |
contourFinder[i].setMaxAreaRadius(200); | |
} | |
} | |
void ofApp::update() { | |
cam.update(); | |
if(cam.isFrameNew()) { | |
for(int i=0; i<MAX_CAMS;i++){ | |
// copy(img[i],cam); | |
copy(cam,img[i]); | |
img[i].update(); | |
contourFinder[i].setThreshold(ofMap(mouseX, 0, ofGetWidth(), 0, 255)); | |
contourFinder[i].findContours(img[i]); | |
} | |
} | |
} | |
void ofApp::draw() { | |
ofSetColor(255); | |
for(int i=0; i<MAX_CAMS;i++){ | |
int rows = i % 3; | |
int cols = i / 3; | |
ofPushMatrix(); | |
ofTranslate(cols*cam.getWidth(), rows*cam.getHeight()); | |
img[i].draw(0, 0); | |
contourFinder[i].draw(); | |
ofPopMatrix(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ofMain.h" | |
#include "ofxCv.h" | |
#define MAX_CAMS 6 | |
class ofApp : public ofBaseApp { | |
public: | |
void setup(); | |
void update(); | |
void draw(); | |
ofVideoGrabber cam; | |
ofImage img[MAX_CAMS]; | |
ofxCv::ContourFinder contourFinder[MAX_CAMS]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment