From 5f68b6655958449b5791ec2ec3cf674289172ee9 Mon Sep 17 00:00:00 2001 From: even <philippe.even@loria.fr> Date: Sun, 11 Nov 2018 23:01:20 +0100 Subject: [PATCH] Hough filter correction --- Code/Seg/BSTools/bsaccumulatoritem.cpp | 2 +- Code/Seg/BlurredSegment/blurredsegment.h | 2 +- .../BlurredSegment/blurredsegmentproto.cpp | 20 ++++--------------- Code/Seg/BlurredSegment/linespacefilter.cpp | 16 ++++++++++----- Code/Seg/BlurredSegment/linespacefilter.h | 2 ++ 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Code/Seg/BSTools/bsaccumulatoritem.cpp b/Code/Seg/BSTools/bsaccumulatoritem.cpp index 3d834ac..73308d0 100755 --- a/Code/Seg/BSTools/bsaccumulatoritem.cpp +++ b/Code/Seg/BSTools/bsaccumulatoritem.cpp @@ -17,7 +17,7 @@ BSAccumulatorItem::BSAccumulatorItem (BSDetector *sd, int w, int h) detector = sd; width = w; height = h; - selaccu = 1; + selaccu = 0; map[0] = NULL; map[1] = NULL; solution[0] = -1; diff --git a/Code/Seg/BlurredSegment/blurredsegment.h b/Code/Seg/BlurredSegment/blurredsegment.h index 0395e78..ca2ce75 100755 --- a/Code/Seg/BlurredSegment/blurredsegment.h +++ b/Code/Seg/BlurredSegment/blurredsegment.h @@ -44,7 +44,7 @@ public: /** * \brief Returns if the segment has non null thickness (not aligned points). */ - inline bool isThick () const { return (dss->width () < 2); } + inline bool isThick () const { return (dss->width () > 1); } /** * \brief Returns the underlying digital straight segment. diff --git a/Code/Seg/BlurredSegment/blurredsegmentproto.cpp b/Code/Seg/BlurredSegment/blurredsegmentproto.cpp index 2354df5..6e2e1a6 100755 --- a/Code/Seg/BlurredSegment/blurredsegmentproto.cpp +++ b/Code/Seg/BlurredSegment/blurredsegmentproto.cpp @@ -36,27 +36,15 @@ BlurredSegmentProto::BlurredSegmentProto (int maxWidth, Pt2i center, { if (scanningRight) { - if (itr == rightPts.end ()) - { - scanningRight = false; - rightOK = true; - } - else plist->addBack (*itr++); + if (itr == rightPts.end ()) scanningRight = false; + else + addRight (*itr++); } if (scanningLeft) { if (itl == leftPts.end ()) scanningLeft = false; else - { - plist->addFront (*itl++); - leftOK = true; - } - } - if (! bsOK && plist->size () > 2) - { - if (! plist->backPoint().colinearTo (plist->frontPoint (), - plist->initialPoint ())) - bsOK = true; + addLeft (*itl++); } } } diff --git a/Code/Seg/BlurredSegment/linespacefilter.cpp b/Code/Seg/BlurredSegment/linespacefilter.cpp index 2745c38..719a8c2 100755 --- a/Code/Seg/BlurredSegment/linespacefilter.cpp +++ b/Code/Seg/BlurredSegment/linespacefilter.cpp @@ -22,6 +22,7 @@ const int LineSpaceFilter::ANG_MAX_ZOOM = 32; const int LineSpaceFilter::DIST_DEF_ZOOM = 4; const int LineSpaceFilter::DIST_MIN_ZOOM = 1; const int LineSpaceFilter::DIST_MAX_ZOOM = 16; +const int LineSpaceFilter::INPUT_MIN_SIZE = 8; LineSpaceFilter::LineSpaceFilter () @@ -63,7 +64,7 @@ BlurredSegment *LineSpaceFilter::filter (BlurredSegment *bs) bsFinalSize = 0; if (bs == NULL || ! bs->isThick ()) return NULL; bsInitialSize = bs->size (); - if (bsInitialSize < 10) return NULL; + if (bsInitialSize < INPUT_MIN_SIZE) return NULL; // Gets the line spacefilter const Pt2i bsstart = bs->getCenter (); @@ -94,11 +95,16 @@ BlurredSegment *LineSpaceFilter::filter (BlurredSegment *bs) fitMask (); // Filters the previous points - for (vector<Pt2i>::const_iterator it = bsleft->begin (); - it != bsleft->end (); it ++) + if (! (bsleft->empty ())) { - if (voteInMask (*it)) leftIn.push_back (Pt2i (*it)); - else out.push_back (Pt2i (*it)); + vector<Pt2i>::const_iterator mit = bsleft->end (); + do + { + mit --; + if (voteInMask (*mit)) leftIn.push_back (Pt2i (*mit)); + else out.push_back (Pt2i (*mit)); + } + while (mit != bsleft->begin ()); } for (vector<Pt2i>::const_iterator it = bsright->begin (); it != bsright->end (); it ++) diff --git a/Code/Seg/BlurredSegment/linespacefilter.h b/Code/Seg/BlurredSegment/linespacefilter.h index 3c6be37..da14661 100755 --- a/Code/Seg/BlurredSegment/linespacefilter.h +++ b/Code/Seg/BlurredSegment/linespacefilter.h @@ -187,6 +187,8 @@ private : static const int DIST_MIN_ZOOM; /** Distance zoom factor max value. */ static const int DIST_MAX_ZOOM; + /** Segment minimal size to accept voting. */ + static const int INPUT_MIN_SIZE; /** Accumulator. */ int *acc; -- GitLab