From c4f88b068794a8fe908180669a274cff41b642e7 Mon Sep 17 00:00:00 2001 From: lluis Date: Tue, 23 Jul 2013 15:04:01 +0200 Subject: [PATCH] removed some unnecessary ERStat members as they are easily computable from others --- .../objdetect/include/opencv2/objdetect/erfilter.hpp | 9 ++------- modules/objdetect/src/erfilter.cpp | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp index 1273688..dcc41c8 100644 --- a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp +++ b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp @@ -79,13 +79,8 @@ public: Rect rect; double raw_moments[2]; //!< order 1 raw moments to derive the centroid double central_moments[3]; //!< order 2 central moments to construct the covariance matrix - std::deque *crossings;//!< horizontal crossings - - //! 1st stage features - float aspect_ratio; - float compactness; - float num_holes; - float med_crossings; + std::deque *crossings;//!< horizontal crossings + float med_crossings; //!< median of the crossings at three different height levels //! 2nd stage features float hole_area_ratio; diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index 37e3519..694f574 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -611,11 +611,6 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child) parent->central_moments[1] += child->central_moments[1]; parent->central_moments[2] += child->central_moments[2]; - // child region done, we can calculate 1st stage features from the incrementally computable descriptors - child->aspect_ratio = (float)(child->rect.width)/(child->rect.height); - child->compactness = sqrt((float)(child->area))/child->perimeter; - child->num_holes = (float)(1-child->euler); - vector m_crossings; m_crossings.push_back(child->crossings->at((int)(child->rect.height)/6)); m_crossings.push_back(child->crossings->at((int)3*(child->rect.height)/6)); @@ -1004,7 +999,11 @@ ERClassifierNM1::ERClassifierNM1() double ERClassifierNM1::eval(const ERStat& stat) { //Classify - float arr[] = {0,stat.aspect_ratio, stat.compactness, stat.num_holes, stat.med_crossings}; + float arr[] = {0,(float)(stat.rect.width)/(stat.rect.height), // aspect ratio + sqrt((float)(stat.area))/stat.perimeter, // compactness + (float)(1-stat.euler), //number of holes + stat.med_crossings}; + vector sample (arr, arr + sizeof(arr) / sizeof(arr[0]) ); float votes = boost.predict( Mat(sample), Mat(), Range::all(), false, true ); @@ -1038,8 +1037,12 @@ ERClassifierNM2::ERClassifierNM2() double ERClassifierNM2::eval(const ERStat& stat) { //Classify - float arr[] = {0,stat.aspect_ratio, stat.compactness, stat.num_holes, stat.med_crossings, - stat.hole_area_ratio, stat.convex_hull_ratio, stat.num_inflexion_points}; + float arr[] = {0,(float)(stat.rect.width)/(stat.rect.height), // aspect ratio + sqrt((float)(stat.area))/stat.perimeter, // compactness + (float)(1-stat.euler), //number of holes + stat.med_crossings, stat.hole_area_ratio, + stat.convex_hull_ratio, stat.num_inflexion_points}; + vector sample (arr, arr + sizeof(arr) / sizeof(arr[0]) ); float votes = boost.predict( Mat(sample), Mat(), Range::all(), false, true ); -- 2.7.4