From 0c2a97dcc0fb370938dc0d2d3a27053c2c9cb31e Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 3 Apr 2012 23:06:21 +0100 Subject: blobs tesselated into textured polys --- gaunt01/src/testApp.cpp | 189 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 144 insertions(+), 45 deletions(-) (limited to 'gaunt01/src/testApp.cpp') diff --git a/gaunt01/src/testApp.cpp b/gaunt01/src/testApp.cpp index 87a51c4..aebbe0b 100644 --- a/gaunt01/src/testApp.cpp +++ b/gaunt01/src/testApp.cpp @@ -4,11 +4,11 @@ //units ~ 10cm // void testApp::setup(){ - + bLearnBakground = true; cam_angle=0; threshold = 80; - + loadSettings("settings.xml"); vidPlayer.loadMovie("camoutput.mov"); //footage/ camera needs to be the same res as opencv planes and output @@ -18,19 +18,24 @@ void testApp::setup(){ hasCamera=true; useCamera=true; } - else + else { hasCamera=false; useCamera=false; vidPlayer.play(); } - colorImg.allocate(640,480); colorImg.setUseTexture(true); grayImage.allocate(640,480); grayBg.allocate(640,480); grayDiff.allocate(640,480); + + blobsManager.normalizePercentage = 0.7; + blobsManager.giveLowestPossibleIDs = true; + blobsManager.maxUndetectedTime = 500; + blobsManager.minDetectedTime = 2000; + blobsManager.debugDrawCandidates = true; ofVec3f centre=ofVec3f(ofGetWidth()/2,0,0); ofVec3f normal=ofVec3f(0,0,-1); @@ -45,59 +50,104 @@ void testApp::setup(){ cam=ofCamera(); cam.setPosition(ofGetWidth()/2,ofGetHeight()/2,-ofGetWidth()); cam.lookAt(ofVec3f(ofGetWidth()/2,ofGetHeight()/2,0),ofVec3f(0, -1, 0)); - cam.setFov(41.0); //39.85); //53.13); + cam.setFov(41.1); //39.85); //53.13); + cam.cacheMatrices(); //stop error messages + + testpts=new ofVec3f[4]; + trapDoor=trapdoor(screen2plane(ofVec2f(ofGetWidth(),0)),screen2plane(ofVec2f(ofGetWidth(),ofGetHeight())),ofVec2f(30,30)); updatePlane(); - + mode=PLAY; + } ofVec2f testApp::screen2plane(ofVec2f screenpos){ ofVec3f p; - ray=projector.castPixel(screenpos.x,screenpos.y); + ray=projector.castPixel(screenpos.x,screenpos.y); bool hit = plane.intersect(ray,p); return ofVec2f(p.x,pow(pow(p.y,2)+pow(p.z,2),0.5f)); } ofVec3f testApp::plane2world(ofVec2f planepos){ return ofVec3f(planepos.x,planepos.y,0); } +bool testApp::rectsCross(ofRectangle rect1,ofRectangle rect2) { + bool overlap=true; //must overlap in x and y + if (rect1.x corners=trapDoor.getCorners(); + ofVec2f screenCorners[4]; + for (int i=0;i newPlayers; float movethresh=10; for (int i = 0; i < contourFinder.nBlobs; i++){ @@ -201,7 +297,7 @@ void testApp::draw(){ ofDrawBitmapString(numStr, r.x, r.y); ofVec3f pp; ray=projector.castPixel(blobBase.x,blobBase.y); //(ofGetHeight()-y)); - bool hit = plane.intersect(ray,pp); + bool hit = plane.intersect(ray,pp); for (int i=0;i