mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Update downsampling filtering approach for ring-like lidars like the ouster
This commit is contained in:
@@ -393,12 +393,61 @@ typename pcl::PointCloud<PointT>::Ptr downsampleImpl(
|
||||
}
|
||||
else
|
||||
{
|
||||
int finalSize = int(cloud->size())/step;
|
||||
output->resize(finalSize);
|
||||
int oi = 0;
|
||||
for(unsigned int i=0; i<cloud->size()-step+1; i+=step)
|
||||
if(cloud->height > 1 && cloud->height < cloud->width/4)
|
||||
{
|
||||
(*output)[oi++] = cloud->at(i);
|
||||
// Assuming ouster point cloud (e.g, 2048x64),
|
||||
// for which the lower dimension is the number of rings.
|
||||
// Downsample each ring by the step.
|
||||
// Example data packed:
|
||||
// <ringA-1, ringB-1, ringC-1, ringD-1;
|
||||
// ringA-2, ringB-2, ringC-2, ringD-2;
|
||||
// ringA-3, ringB-3, ringC-3, ringD-3;
|
||||
// ringA-4, ringB-4, ringC-4, ringD-4>
|
||||
unsigned int rings = cloud->height<cloud->width?cloud->height:cloud->width;
|
||||
unsigned int pts = cloud->height>cloud->width?cloud->height:cloud->width;
|
||||
unsigned int finalSize = rings * pts/step;
|
||||
output->resize(finalSize);
|
||||
output->width = rings;
|
||||
output->height = pts/step;
|
||||
|
||||
for(unsigned int j=0; j<rings; ++j)
|
||||
{
|
||||
for(unsigned int i=0; i<output->height; ++i)
|
||||
{
|
||||
(*output)[i*rings + j] = cloud->at(i*step*rings + j);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(cloud->height > 1)
|
||||
{
|
||||
// assume depth image (e.g., 640x480), downsample like an image
|
||||
UASSERT_MSG(cloud->height % step == 0 && cloud->width % step == 0,
|
||||
uFormat("Decimation of depth images should be exact! (decimation=%d, size=%dx%d)",
|
||||
step, cloud->width, cloud->height).c_str());
|
||||
|
||||
int finalSize = cloud->height/step * cloud->width/step;
|
||||
output->resize(finalSize);
|
||||
output->width = cloud->width/step;
|
||||
output->height = cloud->height/step;
|
||||
|
||||
for(unsigned int j=0; j<output->height; ++j)
|
||||
{
|
||||
for(unsigned int i=0; i<output->width; ++i)
|
||||
{
|
||||
output->at(j*output->width + i) = cloud->at(j*output->width*step + i*step);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int finalSize = int(cloud->size())/step;
|
||||
output->resize(finalSize);
|
||||
int oi = 0;
|
||||
for(unsigned int i=0; i<cloud->size()-step+1; i+=step)
|
||||
{
|
||||
(*output)[oi++] = cloud->at(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
|
||||
Reference in New Issue
Block a user