From 45765dae9ef04cc329ea41a593dcf705b6240cff Mon Sep 17 00:00:00 2001 From: Jonas Jongejan Date: Thu, 16 Jun 2016 16:01:19 -0400 Subject: [PATCH] Rotation fix --- src/ofxFaceTracker2.cpp | 2 +- src/ofxFaceTracker2Instance.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ofxFaceTracker2.cpp b/src/ofxFaceTracker2.cpp index 14583c2..2364369 100755 --- a/src/ofxFaceTracker2.cpp +++ b/src/ofxFaceTracker2.cpp @@ -105,7 +105,7 @@ bool ofxFaceTracker2::update(Mat image, cv::Rect _roi) { } // Update info object - if(info.inputWidth != image.cols || info.inputHeight != image.rows){ + if(info.inputWidth != image.cols || info.inputHeight != image.rows || info.imageRotation != imageRotation){ info = ofxFaceTracker2InputInfo(image.cols, image.rows, im.cols, im.rows, imageRotation); } diff --git a/src/ofxFaceTracker2Instance.cpp b/src/ofxFaceTracker2Instance.cpp index d0626ae..f0f2d72 100644 --- a/src/ofxFaceTracker2Instance.cpp +++ b/src/ofxFaceTracker2Instance.cpp @@ -22,10 +22,11 @@ ofxFaceTracker2Landmarks & ofxFaceTracker2Instance::getLandmarks(){ } ofRectangle ofxFaceTracker2Instance::getBoundingBox() const { - return ofRectangle(rectangle.left(), - rectangle.top(), - rectangle.width(), - rectangle.height()); + ofVec3f tl = ofVec3f(rectangle.tl_corner().x(), rectangle.tl_corner().y(), 0) * info.rotationMatrix; + ofVec3f br = ofVec3f(rectangle.br_corner().x(), rectangle.br_corner().y(), 0) * info.rotationMatrix; + ofVec3f delta = br-tl; + + return ofRectangle(tl.x, tl.y, delta.x, delta.y); } int ofxFaceTracker2Instance::getLabel(){