fix potential segfault due to pointer reference and add ability to set max_norm explicitly #3
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.
Two changes:
In LineSegment3D.hpp,
m_cloud
is a reference to a shared pointer, so it doesn't count towards the shared pointer's reference count. This means that if the originalcloud
as passed into the contructor goes out of scope before theLineSegment3D
does so, the shared pointer thinks it's no longer used and calls its destructor. This leads to a segfault with any further operations on theLineSegment3D
.In HoughTransform.ipp, a use case I've come across a couple times now is that sometimes we know that the origin of a line falls within a certain distance from an initial point—that is, I'm only interested in searching for lines that start there. Allowing
maxNorm
to be set means it's possible to greatly reduce the time taken to find such lines, instead of finding all lines (which would take many orders of magnitude longer) and filtering them down.The new parameter defaults to 0, which maintains the original behavior by using the entire point cloud space. The reason I made it a function parameter rather than a member of
Param
is because restricting the origin search space is a per-operation configuration, rather than one that applies to the entire point cloud. (The workflow I'm using is to instantiate a singleHoughTransform
object, then use it multiple times on different initial points.)