Skip to content

Commit

Permalink
added tracked marker object; removed keyPressed and mode; added track…
Browse files Browse the repository at this point in the history
…er image drawing control; rewrote detect() to only run detector if tracking failed (seems faster)
  • Loading branch information
danomatika committed Apr 5, 2012
1 parent db61dbd commit 710f171
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 165 deletions.
4 changes: 0 additions & 4 deletions ofxFernCameraDemo/ofxFernCameraDemo.xcodeproj/project.pbxproj
Expand Up @@ -16,7 +16,6 @@
30A99808152DE20700F8DBAD /* fine_gaussian_pyramid.cc in Sources */ = {isa = PBXBuildFile; fileRef = 30A997E6152DE20700F8DBAD /* fine_gaussian_pyramid.cc */; };
30A99809152DE20700F8DBAD /* homography06.cc in Sources */ = {isa = PBXBuildFile; fileRef = 30A997E9152DE20700F8DBAD /* homography06.cc */; };
30A9980A152DE20700F8DBAD /* homography_estimator.cc in Sources */ = {isa = PBXBuildFile; fileRef = 30A997EB152DE20700F8DBAD /* homography_estimator.cc */; };
30A9980B152DE20700F8DBAD /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 30A997EE152DE20700F8DBAD /* main.cc */; };
30A9980D152DE20700F8DBAD /* mcv.cc in Sources */ = {isa = PBXBuildFile; fileRef = 30A997F1152DE20700F8DBAD /* mcv.cc */; };
30A9980E152DE20700F8DBAD /* mcvGaussianSmoothing.cc in Sources */ = {isa = PBXBuildFile; fileRef = 30A997F3152DE20700F8DBAD /* mcvGaussianSmoothing.cc */; };
30A9980F152DE20700F8DBAD /* planar_pattern_detector.cc in Sources */ = {isa = PBXBuildFile; fileRef = 30A997F7152DE20700F8DBAD /* planar_pattern_detector.cc */; };
Expand Down Expand Up @@ -102,7 +101,6 @@
30A997EB152DE20700F8DBAD /* homography_estimator.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = homography_estimator.cc; sourceTree = "<group>"; };
30A997EC152DE20700F8DBAD /* homography_estimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = homography_estimator.h; sourceTree = "<group>"; };
30A997ED152DE20700F8DBAD /* keypoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keypoint.h; sourceTree = "<group>"; };
30A997EE152DE20700F8DBAD /* main.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cc; sourceTree = "<group>"; };
30A997F1152DE20700F8DBAD /* mcv.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mcv.cc; sourceTree = "<group>"; };
30A997F2152DE20700F8DBAD /* mcv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mcv.h; sourceTree = "<group>"; };
30A997F3152DE20700F8DBAD /* mcvGaussianSmoothing.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mcvGaussianSmoothing.cc; sourceTree = "<group>"; };
Expand Down Expand Up @@ -293,7 +291,6 @@
30A997EB152DE20700F8DBAD /* homography_estimator.cc */,
30A997EC152DE20700F8DBAD /* homography_estimator.h */,
30A997ED152DE20700F8DBAD /* keypoint.h */,
30A997EE152DE20700F8DBAD /* main.cc */,
30A997F1152DE20700F8DBAD /* mcv.cc */,
30A997F2152DE20700F8DBAD /* mcv.h */,
30A997F3152DE20700F8DBAD /* mcvGaussianSmoothing.cc */,
Expand Down Expand Up @@ -744,7 +741,6 @@
30A99808152DE20700F8DBAD /* fine_gaussian_pyramid.cc in Sources */,
30A99809152DE20700F8DBAD /* homography06.cc in Sources */,
30A9980A152DE20700F8DBAD /* homography_estimator.cc in Sources */,
30A9980B152DE20700F8DBAD /* main.cc in Sources */,
30A9980D152DE20700F8DBAD /* mcv.cc in Sources */,
30A9980E152DE20700F8DBAD /* mcvGaussianSmoothing.cc in Sources */,
30A9980F152DE20700F8DBAD /* planar_pattern_detector.cc in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions ofxFernCameraDemo/src/main.cpp
Expand Up @@ -3,14 +3,14 @@
#include "ofAppGlutWindow.h"

//========================================================================
int main( ){
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
// pass in width and height too:
ofRunApp( new testApp());
ofRunApp(new testApp());

}
43 changes: 39 additions & 4 deletions ofxFernCameraDemo/src/testApp.cpp
Expand Up @@ -3,13 +3,17 @@
//--------------------------------------------------------------
void testApp::setup(){

ofSetFrameRate(60);

int camW = 640;
int camH = 480;

fern.initTracker("model.bmp",camW, camH);
fern.setup("model.bmp", camW, camH);
grabber.initGrabber(camW, camH);
colorImg.allocate(camW, camH);
img.allocate(camW, camH);

showTracker = false;
}

//--------------------------------------------------------------
Expand All @@ -25,16 +29,47 @@ void testApp::update(){

//--------------------------------------------------------------
void testApp::draw(){

ofSetColor(255);
fern.draw(0, 0, 640, 480);
if(showTracker){
fern.draw(0, 0, 640, 480);
}
else{
grabber.draw(0, 0, 640, 480);
}

ofSetHexColor(0xFF0000);
ofNoFill();
if(fern.trackedMarker.tracked) {
fern.trackedMarker.draw();
}

ofDrawBitmapString("keys 1-5 do stuff\nfps: "+ofToString(ofGetFrameRate(), 2), 10, 500);
ofSetColor(255);
ofDrawBitmapString("press 'd' to toggle tracker image\nfps: "+ofToString(ofGetFrameRate(), 2), 10, 10);
}


//--------------------------------------------------------------
void testApp::keyPressed (int key){
fern.keyPressed(key);

switch(key){

case 'd':
showTracker = !showTracker;
break;

case 't':
fern.resetTracker();
break;

case 'k':
fern.showKeypoints(!fern.getShowKeypoints());
break;

case 'l':
fern.showLocations(!fern.getShowLocations());
break;
}
}

//--------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion ofxFernCameraDemo/src/testApp.h
Expand Up @@ -20,9 +20,11 @@ class testApp : public ofBaseApp{
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);

ofVideoGrabber grabber;

ofxCvColorImage colorImg;
ofxCvGrayscaleImage img;
ofxFern fern;

ofVideoGrabber grabber;
bool showTracker;
};

0 comments on commit 710f171

Please sign in to comment.