Repository navigation
Conversation
_adaptive_range_segmentation built a KdTree for every point, and KdTree sorts the list it is given in place, which reordered point_cloud while the loop was iterating over it. points_queue only ever held the starting point, so the while loop ran once per point. Build the tree once from a copy of the point cloud, and compute one neighborhood per point without the queue. _merge_clusters still joins the neighborhoods that share points into one cluster per object. The detected rectangles of point_cloud_rectangle_fitting are unchanged (all 603 rectangles over 201 updates compared with np.random.seed(0)), and the simulation runs in about 8 s instead of 18 s. Closes ShisatoYano#316
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #316
_adaptive_range_segmentationnow builds the kd-tree once, from a copy of the point cloud, before the loop. Building it inside the loop sortedpoint_cloudin place while the loop was iterating over it.I went with the first option from the issue: one neighborhood per point without the queue (which only ever held the starting point), and
_merge_clustersstill joins neighborhoods that share points. It keeps the method short and matches what the code was already doing.How I checked it works
point_cloud_rectangle_fittingwithnp.random.seed(0)before and after: all 603 rectangles over 201 updates are identical. The simulation also runs in about 8 s instead of 18 s.test_segmentation_gives_one_neighborhood_per_point_and_keeps_input_ordertotest/test_l_shape_fitting_detector.py. It fails before the change (the input list gets reordered) and passes after.. run_test_suites.sh: 176 passed.Images
Last frame of
point_cloud_rectangle_fittingwithnp.random.seed(0), before and after (identical):Before:

After:

Book
(section 9.2 is not written yet)