hwo to use pcl to achieve that discretizing the 3D point cloud into a 2D grid over the xy plane, not use the voxelgrid?

pcl tutorials
rgbd to point cloud
point cloud denoise pcl
pcl extract outliers
sor filter

I want to project the 3D point cloud into a 2D grid over the xy plane, each grid cell size is 20cm*20cm, how to achieve it effectively?

NOT use VoxelGrid method, because I want to retain every point and deal with them in the next step(Gaussian kernel every column and use EM to deal with each grid)

As discussed in the comments, you can achieve what you want with OctreePointCloudPointVector class.

Here is an example how to use the class:

#include <pcl/point_cloud.h>
#include <pcl/io/pcd_io.h>
#include <pcl/octree/octree_pointcloud_pointvector.h>

using Cloud    = pcl::PointCloud<pcl::PointXYZ>;
using CloudPtr = Cloud::Ptr;

using OctreeT = pcl::octree::OctreePointCloudPointVector<pcl::PointXYZ>;

int main(int argc, char** argv)
    if(argc < 2)
        return 1;

    // load cloud
    CloudPtr cloud(new Cloud);
    pcl::io::loadPCDFile(argv[1], *cloud);

    CloudPtr cloud_projected(new Cloud(*cloud));
    // project to XY plane
    for(auto& pt : *cloud_projected)
        pt.z = 0.0f;

    // create octree, set resolution to 20cm
    OctreeT octree(0.2);

    // we gonna store the indices of the octree leafs here
    std::vector<std::vector<int>> indices_vec;

    // traverse the octree leafs and store the indices
    const auto it_end = octree.leaf_depth_end();
    for(auto it = octree.leaf_depth_begin(); it != it_end; ++it)
        auto leaf = it.getLeafContainer();
        std::vector<int> indices; 

    // save leafs to file
    int cnt = 0;
    for(const auto indices : indices_vec)
        Cloud leaf(*cloud, indices);
        pcl::io::savePCDFileBinary("leaf_" + std::to_string(cnt++) + ".pcd", leaf);

You can see the output by calling pcl_viewer:

pcl_viewer leaf_*.pcd

See sample output

(PDF) A review of algorithms for filtering the 3D point cloud, What do you mean with 2D grid over the xy plane? Do you still pt.z = 0.0f;. Now you can do normal VoxelGrid on the projected point cloud. Point Cloud Library I PCL is a large scale, open project for 2D/3D image and point cloud processing (in C++, w/ new python bindings). I The PCL framework contains numerous state-of-the art algorithms including ltering, feature estimation, surface reconstruction, registration, model tting and segmentation.

You can achieve this using https://github.com/daavoo/pyntcloud with the following code:

from pyntcloud import PyntCloud

cloud = PyntCloud.from_file("some_cloud.ply")
# 0.2 asumming your point cloud units are meters
voxelgrid_id = cloud.add_structure("voxelgrid", size_x=0.2, size_y=0.2)

voxelgrid = cloud.structures[voxelgrid_id]

You can learn more about VoxelGrid here:


What is a high speed sub-sampling library for big point cloud?, I want to project the 3D point cloud into a 2D grid over the xy plane, each grid cell size is 20cm*20cm, how to achieve it effectively? NOT use VoxelGrid method,  > Hi everyone, > I'm trying to project a 3D plane onto the XY-plane to use with AGAST but I'm > not sure what do I have to do to make the 2D cloud organized. What I did was > just only change the width and height values of the cloud to 640 and 480 > respectively.

What do you mean with 2D grid over the xy plane? Do you still want the z value to be the original value, or do you want to project the point cloud to the XY plane first?

Keep Z value

If you want to keep the Z values, just set the leaf size for Z of VoxelGrid to infinite (or a very large number).

pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
sor.setInputCloud (cloud);
sor.setLeafSize (0.01f, 0.01f, 100000.0f);
sor.filter (*cloud_filtered);
Project Cloud to XY plane first

Project a cloud to the XY plane is nothing else than setting the Z value for each point to 0.

for(auto& pt : cloud)
    pt.z = 0.0f;

Now you can do normal VoxelGrid on the projected point cloud.

New discretization method applied to NBV problem: Semioctree, around. Voxel Grid (VG) filtering method first defines a 3D voxel grid. (3D boxes in 3D space) on a point cloud. Then  I have an unorganized 3D point cloud (I guess unorganized means the points are arranged in a vector form?). For each point, the RGB value is known as well. I want to render the point cloud from different view points around the object to generate a set of 2D training images. Can I do that using PCL or I have to use OpenGL?

3D Imaging Using Photon Counting Lidar on a Moving Platform, OpenVDB creates samples by using Voxels whereas VoxelGrid's quality is lower If there is not any more, how I can implement a high performance algorithm by creates a 3D voxel grid over the input data and approximates all the points in a How to get 3D point cloud representation of 2D images (7 images at different  Hi PCL Users, What is the equivalent in Point Clouds for Intensity in 2D images ? I would like to find an equivalent to comparing intensity of two pixels in image domain to point cloud domain ? If normals are the equivalent, then how to compare two normals (they have x, y and z components ) ? Thanks!

point cloud based: Topics by WorldWideScience.org, All this 3D information, in the form of a point cloud, can be used for the However, the use of an octree structure does not result into Finally, a translation by the floor's plane height, is applied to make it coincident with the XY-​plane. how many occluded voxels have direct LOS from the NBV candidate. If you use the SampleConsensusModel class for fitting a plane inside your input cloud, then, you can get the plane's parameters (i.e., you will know a,b,c,d such that aX+bY+cZ+d = 0, where (X, Y, Z) are points on the plane). From this point on, you can easily compute the transformation matrix between the two coordinate systems: the world cs and

[PDF] Thesis, An odometry system is used to get a first estimate of the sensor trajectory but voxel grid. Which voxel size should be used when extracting a point cloud for the full use statistical information to extract detections not originating from noise. A de- cover the entire illuminated area in the X-Y plane and are called X-Y bins. A. VOXEL_GRID_DILATION - the input cloud will be inserted into a voxel grid with voxels of size voxel_size; this voxel grid will be dilated dilation_iteration_num times and the resulting points will be projected to the MLS surface of the closest point in the input cloud; the result is a point cloud with filled holes and a constant point density.

  • Welcome to Stack Overflow! Please review writing the perfect question to help you to ask a good question, and thus get a good answer.
  • Please take a look at: stackoverflow.com/a/49749230/6812182
  • @Wan Ethan if this resolved your question, can you please mark it as the accepted answer?
  • hi, serkan. I run the code, but I was confused that I cannot find the final result files(the name of leaf_number)when i use visual studio.
  • The files will be written to the path, where VS is running the program from. You can always change the path to an absolute path in pcl::io::savePCDFileBinary().
  • from my understanding, VoxelGrid is a method to achieve down-sampling, which means each output point from the input grid. I want to project the original pointcloud to xy plane and rasterize it, each grid size is 20cm*20cm, and retain every point in the point cloud, not down-sample
  • Ok I see. In that case, I would recommend using OctreePointCloudPointVector. Project your input point cloud to the XY plane first, use that projected point cloud as input for the Octree. Afterwards, you will have the indices of the points from the input point cloud in each of the voxels.
  • yeah, I actually achieve the projection to xy plane, but I am confused by the rasterize. my projection method is pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients()); coefficients->values.resize(4); coefficients->values[0] = 0; coefficients->values[1] = 0; coefficients->values[2] = 1; coefficients->values[3] = 0;
  • thank you for your reply, I actually search the Octree method, I am confused by something. The first thing is that whether the voxel by Octree is empty inside but just represent like a pixel on 2D plane. The second problem is that If I want know the disribution inside grid, what should I do?
  • @WanEthan I am gonna show you how to achieve what you want in a separate answer.