From bedd1f763cafc8d23a89ef8aad5c9ed92d932f43 Mon Sep 17 00:00:00 2001 From: Vladislav Sovrasov Date: Fri, 18 Nov 2016 17:17:12 +0300 Subject: [PATCH] Replace a dummy pointer with the smart in ERStat --- modules/text/include/opencv2/text/erfilter.hpp | 2 +- modules/text/src/erfilter.cpp | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/text/include/opencv2/text/erfilter.hpp b/modules/text/include/opencv2/text/erfilter.hpp index 9303e128f..af983c6c1 100644 --- a/modules/text/include/opencv2/text/erfilter.hpp +++ b/modules/text/include/opencv2/text/erfilter.hpp @@ -82,7 +82,7 @@ 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 + Ptr > crossings;//!< horizontal crossings float med_crossings; //!< median of the crossings at three different height levels //! 2nd stage features diff --git a/modules/text/src/erfilter.cpp b/modules/text/src/erfilter.cpp index 7050f4632..5d1ed8f9b 100644 --- a/modules/text/src/erfilter.cpp +++ b/modules/text/src/erfilter.cpp @@ -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[1] = 0.0; central_moments[2] = 0.0; - crossings = new deque(); + crossings = makePtr >(); crossings->push_back(0); } @@ -526,9 +526,7 @@ void ERFilterNM::er_tree_extract( InputArray image ) ERStat *stat = er_stack.at(r); if (stat->crossings) { - stat->crossings->clear(); - delete(stat->crossings); - stat->crossings = NULL; + stat->crossings.release(); } deleteERStatTree(stat); } @@ -665,9 +663,7 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child) child->med_crossings = (float)m_crossings.at(1); // free unnecessary mem - child->crossings->clear(); - delete(child->crossings); - child->crossings = NULL; + child->crossings.release(); // recover the original grey-level child->level = child->level*thresholdDelta; @@ -714,9 +710,7 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child) // free mem if(child->crossings) { - child->crossings->clear(); - delete(child->crossings); - child->crossings = NULL; + child->crossings.release(); } delete(child); }