1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Make LineSegmentDetector deterministic by using stable_sort for ordering keypoints prior to region growing

This makes LineSegmentDetector deterministic by using stable_sort for ordering points by norm. Without this change the region growing in LSD is non-determinstic and thus the returned lines are changing between invocations.

This is a replacement for https://github.com/opencv/opencv/pull/23370
This commit is contained in:
Simon Lynen
2023-03-22 04:12:51 +01:00
committed by GitHub
parent a924bbfc30
commit 6033599c88
+2 -2
View File
@@ -592,8 +592,8 @@ void LineSegmentDetectorImpl::ll_angle(const double& threshold,
}
}
// Sort
std::sort(ordered_points.begin(), ordered_points.end(), compare_norm);
// Use stable sort to ensure deterministic region growing and thus overall LSD result determinism.
std::stable_sort(ordered_points.begin(), ordered_points.end(), compare_norm);
}
void LineSegmentDetectorImpl::region_grow(const Point2i& s, std::vector<RegionPoint>& reg,