From a47b39541a7f60dfdda921c9598abe947e1e6ad9 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 28 Mar 2012 00:42:08 +0100 Subject: rayhit still iffy. starting morpher --- gaunt01/addons.make | 1 + gaunt01/config.make | 2 +- gaunt01/gaunt01.cbp | 6 ++++ gaunt01/gaunt01.layout | 9 +++-- gaunt01/src/main.cpp | 2 +- gaunt01/src/testApp.cpp | 94 +++++++++++++++++++++++++++++++++++++------------ gaunt01/src/testApp.h | 8 +++++ 7 files changed, 94 insertions(+), 28 deletions(-) (limited to 'gaunt01') diff --git a/gaunt01/addons.make b/gaunt01/addons.make index 886857d..9e525f4 100644 --- a/gaunt01/addons.make +++ b/gaunt01/addons.make @@ -1 +1,2 @@ ofxOpenCv +ofxRay diff --git a/gaunt01/config.make b/gaunt01/config.make index 702abf0..9ce3e2f 100644 --- a/gaunt01/config.make +++ b/gaunt01/config.make @@ -3,7 +3,7 @@ # OF_ROOT allows to move projects outside apps/* just set this variable to the # absoulte path to the OF root folder -OF_ROOT = ../../of_preRelease_v007_linux +OF_ROOT = ../../openFrameworks-020912 # USER_CFLAGS allows to pass custom flags to the compiler diff --git a/gaunt01/gaunt01.cbp b/gaunt01/gaunt01.cbp index a53c7b0..1ad4c32 100644 --- a/gaunt01/gaunt01.cbp +++ b/gaunt01/gaunt01.cbp @@ -81,6 +81,12 @@ + + + + diff --git a/gaunt01/gaunt01.layout b/gaunt01/gaunt01.layout index 04e7795..e5fb8e8 100644 --- a/gaunt01/gaunt01.layout +++ b/gaunt01/gaunt01.layout @@ -1,13 +1,16 @@ + + + - + - + - + diff --git a/gaunt01/src/main.cpp b/gaunt01/src/main.cpp index 6a32c6a..e502a4d 100644 --- a/gaunt01/src/main.cpp +++ b/gaunt01/src/main.cpp @@ -6,7 +6,7 @@ int main( ){ ofAppGlutWindow window; - ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context + ofSetupOpenGL(&window, 640,480, OF_WINDOW); // <-------- setup the GL context // this kicks off the running of my app // can be OF_WINDOW or OF_FULLSCREEN diff --git a/gaunt01/src/testApp.cpp b/gaunt01/src/testApp.cpp index fdff756..00658b4 100644 --- a/gaunt01/src/testApp.cpp +++ b/gaunt01/src/testApp.cpp @@ -18,6 +18,23 @@ void testApp::setup(){ bLearnBakground = true; threshold = 80; + + ofVec3f centre=ofVec3f(ofGetWidth()/2,0,0); + ofVec3f normal=ofVec3f(0,0,-1); + ray=ofRay(); + plane=ofPlane(centre,normal); + plane.color=ofColor(255,255,255); + + projector=ofProjector(1.535f, ofVec2f(0.0f, 0.5f),ofGetWidth(),ofGetHeight()); + projector.setPosition(ofGetWidth()/2,ofGetHeight()/2,ofGetHeight()); + + cam=ofCamera(); + cam.setPosition(ofGetWidth()/2,ofGetHeight()/2,ofGetHeight()); + cam.lookAt(ofVec3f(ofGetWidth()/2,ofGetHeight()/2,0)); + cam.setFov(54.13); + + cam_angle=0; + } //-------------------------------------------------------------- @@ -54,7 +71,7 @@ void testApp::update(){ // find contours which are between the size of 20 pixels and 1/3 the w*h pixels. // also, find holes is set to true so we will get interior contours as well.... - contourFinder.findContours(grayDiff, 20, (340*240)/3, 10, true); // find holes + contourFinder.findContours(grayDiff, 20, (340*240)/3, 10, false); // don't find holes } } @@ -62,6 +79,7 @@ void testApp::update(){ //-------------------------------------------------------------- void testApp::draw(){ + /* // draw the incoming, the grayscale, the bg and the thresholded difference ofSetHexColor(0xffffff); colorImg.draw(20,20); @@ -70,45 +88,68 @@ void testApp::draw(){ grayDiff.draw(360,280); // then draw the contours: - + */ ofFill(); ofSetHexColor(0x333333); - ofRect(360,540,320,240); - ofSetHexColor(0xffffff); + //ofRect(360,540,320,240); + ofSetHexColor(0xa0a0a0); // we could draw the whole contour finder //contourFinder.draw(360,540); - // or, instead we can draw each blob individually, - // this is how to get access to them: - for (int i = 0; i < contourFinder.nBlobs; i++){ - contourFinder.blobs[i].draw(360,540); - } - // finally, a report: - - ofSetHexColor(0xffffff); - char reportStr[1024]; - sprintf(reportStr, "bg subtraction and blob detection\npress ' ' to capture bg\nthreshold %i (press: +/-)\nnum blobs found %i, fps: %f", threshold, contourFinder.nBlobs, ofGetFrameRate()); - ofDrawBitmapString(reportStr, 20, 600); + colorImg.draw(0,0,ofGetWidth(),ofGetHeight()); - float gap=ofGetHeight()-ofGetWidth(); + cam.begin(); + ofPushMatrix(); - ofTranslate(0,ofGetHeight(),0); ofRotate(cam_angle,1,0,0); - ofTranslate(0,-ofGetHeight(),0); - for (float i=0;i