Commit 3ca7717e authored by Daniel Angelov's avatar Daniel Angelov

Fixed scanning bug identified in comments in pull request #1119.

NFA calculations now generate better line segments.
parent 983799d3
...@@ -1067,13 +1067,17 @@ double LineSegmentDetectorImpl::rect_nfa(const rect& rec) const ...@@ -1067,13 +1067,17 @@ double LineSegmentDetectorImpl::rect_nfa(const rect& rec) const
double left_x = min_y->p.x, right_x = min_y->p.x; double left_x = min_y->p.x, right_x = min_y->p.x;
// Loop around all points in the region and count those that are aligned. // Loop around all points in the region and count those that are aligned.
int min_iter = std::max(min_y->p.y, 0); int min_iter = min_y->p.y;
int max_iter = std::min(max_y->p.y, img_height - 1); int max_iter = max_y->p.y;
for(int y = min_iter; y <= max_iter; ++y) for(int y = min_iter; y <= max_iter; ++y)
{ {
if (y < 0 || y >= img_height) continue;
int adx = y * img_width + int(left_x); int adx = y * img_width + int(left_x);
for(int x = int(left_x); x <= int(right_x); ++x, ++adx) for(int x = int(left_x); x <= int(right_x); ++x, ++adx)
{ {
if (x < 0 || x >= img_width) continue;
++total_pts; ++total_pts;
if(isAligned(adx, rec.theta, rec.prec)) if(isAligned(adx, rec.theta, rec.prec))
{ {
......
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