Skip to content

Commit c4f88b0

Browse files
committed
removed some unnecessary ERStat members as they are easily computable from others
1 parent 43e7e6e commit c4f88b0

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

modules/objdetect/include/opencv2/objdetect/erfilter.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,8 @@ struct CV_EXPORTS ERStat
7979
Rect rect;
8080
double raw_moments[2]; //!< order 1 raw moments to derive the centroid
8181
double central_moments[3]; //!< order 2 central moments to construct the covariance matrix
82-
std::deque<int> *crossings;//!< horizontal crossings
83-
84-
//! 1st stage features
85-
float aspect_ratio;
86-
float compactness;
87-
float num_holes;
88-
float med_crossings;
82+
std::deque<int> *crossings;//!< horizontal crossings
83+
float med_crossings; //!< median of the crossings at three different height levels
8984

9085
//! 2nd stage features
9186
float hole_area_ratio;

modules/objdetect/src/erfilter.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,6 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child)
611611
parent->central_moments[1] += child->central_moments[1];
612612
parent->central_moments[2] += child->central_moments[2];
613613

614-
// child region done, we can calculate 1st stage features from the incrementally computable descriptors
615-
child->aspect_ratio = (float)(child->rect.width)/(child->rect.height);
616-
child->compactness = sqrt((float)(child->area))/child->perimeter;
617-
child->num_holes = (float)(1-child->euler);
618-
619614
vector<int> m_crossings;
620615
m_crossings.push_back(child->crossings->at((int)(child->rect.height)/6));
621616
m_crossings.push_back(child->crossings->at((int)3*(child->rect.height)/6));
@@ -1004,7 +999,11 @@ ERClassifierNM1::ERClassifierNM1()
1004999
double ERClassifierNM1::eval(const ERStat& stat)
10051000
{
10061001
//Classify
1007-
float arr[] = {0,stat.aspect_ratio, stat.compactness, stat.num_holes, stat.med_crossings};
1002+
float arr[] = {0,(float)(stat.rect.width)/(stat.rect.height), // aspect ratio
1003+
sqrt((float)(stat.area))/stat.perimeter, // compactness
1004+
(float)(1-stat.euler), //number of holes
1005+
stat.med_crossings};
1006+
10081007
vector<float> sample (arr, arr + sizeof(arr) / sizeof(arr[0]) );
10091008

10101009
float votes = boost.predict( Mat(sample), Mat(), Range::all(), false, true );
@@ -1038,8 +1037,12 @@ ERClassifierNM2::ERClassifierNM2()
10381037
double ERClassifierNM2::eval(const ERStat& stat)
10391038
{
10401039
//Classify
1041-
float arr[] = {0,stat.aspect_ratio, stat.compactness, stat.num_holes, stat.med_crossings,
1042-
stat.hole_area_ratio, stat.convex_hull_ratio, stat.num_inflexion_points};
1040+
float arr[] = {0,(float)(stat.rect.width)/(stat.rect.height), // aspect ratio
1041+
sqrt((float)(stat.area))/stat.perimeter, // compactness
1042+
(float)(1-stat.euler), //number of holes
1043+
stat.med_crossings, stat.hole_area_ratio,
1044+
stat.convex_hull_ratio, stat.num_inflexion_points};
1045+
10431046
vector<float> sample (arr, arr + sizeof(arr) / sizeof(arr[0]) );
10441047

10451048
float votes = boost.predict( Mat(sample), Mat(), Range::all(), false, true );

0 commit comments

Comments
 (0)