Commit b1cd048a authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #857 from sovrasov:text_erstat_smartptr

parents 4c1cbc87 bedd1f76
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
Rect rect; Rect rect;
double raw_moments[2]; //!< order 1 raw moments to derive the centroid 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 double central_moments[3]; //!< order 2 central moments to construct the covariance matrix
std::deque<int> *crossings;//!< horizontal crossings Ptr<std::deque<int> > crossings;//!< horizontal crossings
float med_crossings; //!< median of the crossings at three different height levels float med_crossings; //!< median of the crossings at three different height levels
//! 2nd stage features //! 2nd stage features
......
...@@ -97,7 +97,7 @@ ERStat::ERStat(int init_level, int init_pixel, int init_x, int init_y) : pixel(i ...@@ -97,7 +97,7 @@ ERStat::ERStat(int init_level, int init_pixel, int init_x, int init_y) : pixel(i
central_moments[0] = 0.0; central_moments[0] = 0.0;
central_moments[1] = 0.0; central_moments[1] = 0.0;
central_moments[2] = 0.0; central_moments[2] = 0.0;
crossings = new deque<int>(); crossings = makePtr<deque<int> >();
crossings->push_back(0); crossings->push_back(0);
} }
...@@ -526,9 +526,7 @@ void ERFilterNM::er_tree_extract( InputArray image ) ...@@ -526,9 +526,7 @@ void ERFilterNM::er_tree_extract( InputArray image )
ERStat *stat = er_stack.at(r); ERStat *stat = er_stack.at(r);
if (stat->crossings) if (stat->crossings)
{ {
stat->crossings->clear(); stat->crossings.release();
delete(stat->crossings);
stat->crossings = NULL;
} }
deleteERStatTree(stat); deleteERStatTree(stat);
} }
...@@ -665,9 +663,7 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child) ...@@ -665,9 +663,7 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child)
child->med_crossings = (float)m_crossings.at(1); child->med_crossings = (float)m_crossings.at(1);
// free unnecessary mem // free unnecessary mem
child->crossings->clear(); child->crossings.release();
delete(child->crossings);
child->crossings = NULL;
// recover the original grey-level // recover the original grey-level
child->level = child->level*thresholdDelta; child->level = child->level*thresholdDelta;
...@@ -714,9 +710,7 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child) ...@@ -714,9 +710,7 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child)
// free mem // free mem
if(child->crossings) if(child->crossings)
{ {
child->crossings->clear(); child->crossings.release();
delete(child->crossings);
child->crossings = NULL;
} }
delete(child); delete(child);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment