Skip to content

Commit

Permalink
Merge pull request #15 from yTb45/master
Browse files Browse the repository at this point in the history
Update interface.cpp
Fixes crash with single color images (when no lines are detected)
  • Loading branch information
RomanJuranek authored Nov 9, 2023
2 parents a4eb498 + f340edf commit a10eeea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ LineSegment * find_line_segment_groups(
// Detect the lines
auto lines = find_line_segments(im, SEED_DIST, SEED_RATIO, TRACE_TOLERANCE, ctx);

if (lines.size() < 2)
{
*n_lines = 0;
return nullptr;
}

if (refine)
{
lines = postprocess_lines_segments(lines, ctx);
Expand All @@ -56,6 +62,12 @@ LineSegment * find_line_segment_groups(
filtered.reserve(lines.size());
_filter_lines(lines.begin(), lines.end(), back_inserter(filtered), min_length);

if (filtered.size() == 0)
{
*n_lines = 0;
return nullptr;
}

estimate_line_pencils(filtered, MAX_MODELS, ESTIMATOR_INLIER_MAX_ANGLE_DEG, ESTIMATOR_GARBAGE_MAX_ANGLE_DEG, ctx);
auto & groupped = filtered;

Expand Down

0 comments on commit a10eeea

Please sign in to comment.