I'v got 2 point clouds (in mm unit), one is a "mesh" sampled from stl object (99999 points), and second is point cloud of this object taken by 3D cam (about 30841 points). I am using this PCL tutorial's code for template matching: http://pointclouds.org/documentation/tutorials/template_alignment.php. After that, I am using PCL ICP code for final alignment. But I am still getting quite bad initial guess from Template Alignment. (eg. no rotation, half-match,...)
I tried change settings from:
normal_radius_(0.02f)
feature_radius_(0.02f)
min_sample_distance_(0.05f)
max_correspondence_distance_(0.01f * 0.01f)
nr_iterations_(50)
to this one:
normal_radius_(2.0f)
feature_radius_(2.0f)
min_sample_distance_(0.5f)
max_correspondence_distance_(1.0f * 1.0f)
nr_iterations_(1000)
Can someone please give me some hints how to improve this code? Thanks!
Parameters which are resolution-dependent should be also set in relation to the resolution of the point cloud. Paramerets which are object-size-dependent should be also set in relation to the size of the object.
Some examples:
normal_radius: 4-8 * <resolution>
mm
, then you chose a radius of 2mm
, which is way too small.feature_radius: 1-2 * <normal_radius>
max_correspondence_distance:
You set this value to 1mm*1mm
, which means, that correspondeces can only be 1mm
apart to be categorized as correspondences. Here it is important to use a value which is in relation to your object's size. You should ask yourself, "What's the maximum allowed distance between my object and reference such that my object is still a match?" If you are comparing faces, you should use some centimeter
s, e.g. 1cm-5cm
, since a face is rather small. But let's say you want to compare big objects like buildings. There you can use values up to 1m
.min_sample_distance:
Here almost the same applies as for max_correspondence_distance
. You should ask yourself, "How much should a sample be distant from another sample?". The smaller the value, the more samples you'll get. Again, choose a value which is a fraction of your object's size, but also consider that it shouldn't be smaller than your cloud's resolution. You set it to 0.5mm
, which is way too small.nr_iterations:
Usually not that important, but values between 100-500
are reasonable.