Skip to content

Commit

Permalink
added setHaarMinSize() and fixed typo with getHaarFound()
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemcdonald committed Oct 30, 2013
1 parent 72e99de commit defb6b1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion example-empty/src/main.cpp
Expand Up @@ -3,6 +3,6 @@

int main() {
ofAppGlutWindow window;
ofSetupOpenGL(&window, 640, 480, OF_WINDOW);
ofSetupOpenGL(&window, 1280, 720, OF_WINDOW);
ofRunApp(new testApp());
}
27 changes: 5 additions & 22 deletions example-empty/src/testApp.cpp
Expand Up @@ -3,12 +3,8 @@
using namespace ofxCv;

void testApp::setup() {
ofSetVerticalSync(true);
ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
cam.initGrabber(640, 480);

cam.initGrabber(1280, 720);
tracker.setup();
tracker.setRescale(.5);
}

void testApp::update() {
Expand All @@ -19,25 +15,12 @@ void testApp::update() {
}

void testApp::draw() {
ofSetColor(255);
cam.draw(0, 0);
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);

ofPolyline leftEye = tracker.getImageFeature(ofxFaceTracker::LEFT_EYE);
ofPolyline rightEye = tracker.getImageFeature(ofxFaceTracker::RIGHT_EYE);
ofPolyline faceOutline = tracker.getImageFeature(ofxFaceTracker::FACE_OUTLINE);

ofSetLineWidth(2);
ofSetColor(ofColor::red);
leftEye.draw();
ofSetColor(ofColor::green);
rightEye.draw();
ofSetColor(ofColor::blue);
faceOutline.draw();

ofSetLineWidth(1);
ofSetColor(255);
tracker.draw(true);
tracker.draw();
ofNoFill();
ofRect(tracker.getHaarRectangle());
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
}

void testApp::keyPressed(int key) {
Expand Down
1 change: 1 addition & 0 deletions libs/FaceTracker/include/FaceTracker/FDet.h
Expand Up @@ -49,6 +49,7 @@ namespace FACETRACKER
class FDet{
public:
int _haar_count;
cv::Rect _haar_rect;
int _min_neighbours; /**< see OpenCV documentation */
int _min_size; /**< ... */
double _img_scale; /**< ... */
Expand Down
3 changes: 2 additions & 1 deletion libs/FaceTracker/src/lib/FDet.cc
Expand Up @@ -90,7 +90,7 @@ cv::Rect FDet::Detect(cv::Mat im)
cvClearMemStorage(storage_); IplImage simg = small_img_;
CvSeq* obj = cvHaarDetectObjects(&simg,_cascade,storage_,
_scale_factor,_min_neighbours,0,
cv::Size(_min_size,_min_size));
cv::Size(_min_size/_img_scale,_min_size/_img_scale));
_haar_count = obj->total;
if(obj->total == 0)return cv::Rect(0,0,0,0);
for(i = 0,maxv = 0; i < obj->total; i++){
Expand All @@ -100,6 +100,7 @@ cv::Rect FDet::Detect(cv::Mat im)
R.width = r->width*_img_scale; R.height = r->height*_img_scale;
}
}
_haar_rect = R;
cvRelease((void**)(&obj)); return R;
}
//===========================================================================
Expand Down
9 changes: 7 additions & 2 deletions src/ofxFaceTracker.cpp
Expand Up @@ -153,7 +153,7 @@ bool ofxFaceTracker::getFound() const {
return !failed;
}

bool ofxFaceTracker::getHaardFound() const {
bool ofxFaceTracker::getHaarFound() const {
return tracker._fdet._haar_count > 0;
}

Expand Down Expand Up @@ -235,6 +235,11 @@ const Mat& ofxFaceTracker::getObjectPointsMat() const {
return objectPoints;
}

ofRectangle ofxFaceTracker::getHaarRectangle() const {
cv::Rect rect = tracker._fdet._haar_rect;
return ofRectangle(rect.x / rescale, rect.y / rescale, rect.width / rescale, rect.height / rescale);
}

ofVec2f ofxFaceTracker::getPosition() const {
const Mat& pose = tracker._clm._pglobl;
return ofVec2f(pose.db(4,0), pose.db(5,0)) / rescale;
Expand Down Expand Up @@ -336,7 +341,7 @@ void ofxFaceTracker::setUseInvisible(bool useInvisible) {
}

void ofxFaceTracker::setHaarMinSize(float minSize) {
tracker._fdet._min_size = minSize;
tracker._fdet._min_size = minSize * rescale;
}

void ofxFaceTracker::updateObjectPoints() {
Expand Down
3 changes: 2 additions & 1 deletion src/ofxFaceTracker.h
Expand Up @@ -29,7 +29,7 @@ class ofxFaceTracker {

int size() const;
bool getFound() const;
bool getHaardFound() const;
bool getHaarFound() const;
int getAge() const;
virtual bool getVisibility(int i) const;

Expand All @@ -48,6 +48,7 @@ class ofxFaceTracker {

virtual const cv::Mat& getObjectPointsMat() const;

virtual ofRectangle getHaarRectangle() const;
virtual ofVec2f getPosition() const;
virtual float getScale() const;
virtual ofVec3f getOrientation() const;
Expand Down

0 comments on commit defb6b1

Please sign in to comment.