Organized Point cloud

Feel free to ask any question here
Post Reply
danics
Posts: 2
Joined: Tue Sep 09, 2014 3:23 pm

Organized Point cloud

Post by danics »

Hi,

first of all thank you for your beautiful application and beautiful codin too i m so glad working with this app. :D thank you again

secondly i m sorry if you answer this question before i couldnt find it in forum anyway!

i want add a filter to your qPcl plugin and i m new to pcl library too, however i use pcl 1.7 and i want create a organized point cloud from your cloud without success can you guid me to do this?,
this is my code for extracting edges:

Code: Select all

ccPointCloud * cloud = getSelectedEntityAsCCPointCloud();
	if (!cloud)
        return -1;

    //if we have normals delete them!
    if (cloud->hasNormals())
        cloud->unallocateNorms();

    PCLCloud::Ptr out_cloud(new PCLCloud);

    cc2smReader converter;
    converter.setInputCloud(cloud);
    int result = converter.getAsSM(*out_cloud);

    if (result != 1)
    {
        return -31;
    }

    CloudPtr pcloud (new Cloud);
    fromPCLPointCloud2 (*out_cloud, *pcloud);
    pcl::PointCloud<pcl::Normal>::Ptr normal (new pcl::PointCloud<pcl::Normal>);
    pcl::IntegralImageNormalEstimation<PointXYZRGBA, pcl::Normal> ne;
    ne.setNormalEstimationMethod (ne.COVARIANCE_MATRIX);
    ne.setNormalSmoothingSize (10.0f);
    ne.setBorderPolicy (ne.BORDER_POLICY_MIRROR);
    ne.setInputCloud (pcloud);
    ne.compute (*normal);

    //OrganizedEdgeBase<PointXYZRGBA, Label> oed;
    //OrganizedEdgeFromRGB<PointXYZRGBA, Label> oed;
    //OrganizedEdgeFromNormals<PointXYZRGBA, Normal, Label> oed;
    OrganizedEdgeFromRGB<PointXYZRGBA, Label> oed;
    oed.setInputNormals (normal);
    oed.setInputCloud (pcloud);
    oed.setDepthDisconThreshold (default_th_dd);
    oed.setMaxSearchNeighbors (default_max_search);
    oed.setEdgeType (oed.EDGELABEL_NAN_BOUNDARY | oed.EDGELABEL_OCCLUDING | oed.EDGELABEL_OCCLUDED | oed.EDGELABEL_HIGH_CURVATURE | oed.EDGELABEL_RGB_CANNY);
    PointCloud<Label> labels;
    std::vector<PointIndices> label_indices;
    oed.compute (labels, label_indices);

    // Make gray point clouds
    for (size_t idx = 0; idx < pcloud->points.size (); idx++)
    {
        uint8_t gray = uint8_t ((pcloud->points[idx].r + pcloud->points[idx].g + pcloud->points[idx].b) / 3);
        pcloud->points[idx].r = pcloud->points[idx].g = pcloud->points[idx].b = gray;
    }

    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr occluding_edges (new pcl::PointCloud<pcl::PointXYZRGBA>),
    occluded_edges (new pcl::PointCloud<pcl::PointXYZRGBA>),
    nan_boundary_edges (new pcl::PointCloud<pcl::PointXYZRGBA>),
    high_curvature_edges (new pcl::PointCloud<pcl::PointXYZRGBA>),
    rgb_edges (new pcl::PointCloud<pcl::PointXYZRGBA>);
    pcl::copyPointCloud (*pcloud, label_indices[0].indices, *nan_boundary_edges);
    pcl::copyPointCloud (*pcloud, label_indices[1].indices, *occluding_edges);
    pcl::copyPointCloud (*pcloud, label_indices[2].indices, *occluded_edges);
    pcl::copyPointCloud (*pcloud, label_indices[3].indices, *high_curvature_edges);
    pcl::copyPointCloud (*pcloud, label_indices[4].indices, *rgb_edges);
and IntegralImageNormalEstimation get error input point cloud is not organized,

and if you can please tell the best way for finding label_indices match points in ccPointCloud ?

thanks in advancs
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Organized Point cloud

Post by daniel »

Hi,

I'll ask Luca (the creator of this plugin) if he can look at your post and answer you. I'm just as a PCL noob as you (maybe worst ;).
Daniel, CloudCompare admin
danics
Posts: 2
Joined: Tue Sep 09, 2014 3:23 pm

Re: Organized Point cloud

Post by danics »

thanks for your consideration :)
luke_penn
Posts: 13
Joined: Sun Oct 23, 2011 3:54 pm

Re: Organized Point cloud

Post by luke_penn »

hi danics, I see what the problem is. The cloudcompare representation of a point cloud is a simple list of points without any specific structure. In pcl they use two different reprensetation of point clouds.
See here http://docs.pointclouds.org/trunk/class ... cloud.html
A point cloud has two public attribute width and height which works like width and height of an image. If the given cloud is structured it will have e.g. 640x480 (width x height) pixels. If the cloud is not structured these values would be something like 307200 x 1.

in the first case the cloud is a matrix of depth values, that associated with the parameters of the camera gives you points in space. This kind of rapresentation is slower when visualizing the cloud (you need to project each time the points in the 3d space) but is faster for some operations (you can perform easily convolution using FFT and edge detection like it was a common rgb image adding some constrains...)

The problem here is that cc2smReader always converts the cloudcompare cloud in a PCL unstructured cloud so that some PCL algorithms which are made for structured clouds will not work with the unstructured clouds.

From structured to unstructured is fairly easy but vice-versa require some kind of resampling and interpolation.

See http://www.pcl-users.org/How-to-convert ... 33742.html or other post in PCL forum.

Actually would be really nice if cloudcompare would provide a cloud object that can also store structured point clouds...

Hope it helps. Let me know if I can help you in any other way!

Luca
Post Reply