CloudViewer doesn't display correctly an organized point cloud

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

CloudViewer doesn't display correctly an organized point cloud

Eduardo Fernandez
Visualization with CloudViewer doesn't work with downsampled organized point clouds. After spending some time around the problem I see that the fact of containing NaN points produces this wrong visualization. I've seen this wrong visualization in two ways, first with wrong color (it looks like an interference with fringes), and second with a very scattered point cloud which doesn't correspond with the scene. I have experienced the same problem when only copying a point cloud received by the OpenNIGrabber (copying every single point) as shown below:

pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pointCloudPtr; //This is the pointer to the point cloud received by OpenNIGrabber
pcl::visualization::CloudViewer cloudViewer("viewer");


    pcl::PointCloud<pcl::PointXYZRGBA> copyPointCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA> );
    copyPointCloudPtr->points.resize(pointCloudPtr->size());
    for(int pt=0;pt<pointCloudPtr->size();pt++)
      copyPointCloudPtr->points[pt] = pointCloudPtr->points[pt];
    copyPointCloudPtr->width = 640;
    copyPointCloudPtr->height = 480;
    ...
    cloudViewer.showCloud(copyPointCloudPtr);


This results in such wrong visualization!!! In exchange, when doing the copy to an unorganized point cloud (not copying the NaN points) the visualization looks OK.


    pcl::PointCloud<pcl::PointXYZRGBA> copyPointCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA> );
    copyPointCloudPtr->points.resize(pointCloudPtr->size());
    int finitePt = 0;
    for(int pt=0;pt<pointCloudPtr->size();pt++)
      if( pcl_isfinite(pointCloudPtr->points[pt].x) )
      {
        copyPointCloudPtr->points[finitePt] = pointCloudPtr->points[pt];
        ++finitePt;
      }
    copyPointCloudPtr->width = finitePt;
    copyPointCloudPtr->height = 1;
    ...
    cloudViewer.showCloud(copyPointCloudPtr);


Any ideas about why this happens?


Thanks in advance,
Edu Fdez
Reply | Threaded
Open this post in threaded view
|

Re: CloudViewer doesn't display correctly an organized point cloud

Eduardo Fernandez
I think that I've found out the reason why the visualization went wrong. I've done the same experiment to maintain the cloud organized but without copying NaN points and it works. So, I guess that the right thing to do is to leave empty the point in copyPointCloudPtr->points[pt] rather than copying a NaN.

Below you can see the changed code:

   for(int pt=0;pt<pointCloudPtr->size();pt++)
     if( pcl_isfinite(pointCloudPtr->points[pt].x) )
       copyPointCloudPtr->points[pt] = pointCloudPtr->points[pt];
Reply | Threaded
Open this post in threaded view
|

Re: CloudViewer doesn't display correctly an organized point cloud

Eduardo Fernandez
Still no clue about why a point cloud which contains NaN points isn't properly displayed neither with PCLVisualizer nor with CloudViewer. Any ideas?

Edu Fdez
Reply | Threaded
Open this post in threaded view
|

Re: CloudViewer doesn't display correctly an organized point cloud

KEN yeh
This post has NOT been accepted by the mailing list yet.
In reply to this post by Eduardo Fernandez
the cloud viewer argument should be pointer

try this
    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr copyPointCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA> );  
Reply | Threaded
Open this post in threaded view
|

Re: CloudViewer doesn't display correctly an organized point cloud

Eduardo Fernandez
Ken, many thanks for your reply,

actually I made I mistake when copying the example here, in my code I was passing a pointer to the CloudViewer (as you say)

 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr copyPointCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA> );

The error may likely be related to the NAN points that are in the cloud since when I remove these NAN points the visualization works OK. Any idea about this?
Reply | Threaded
Open this post in threaded view
|

Re: CloudViewer doesn't display correctly an organized point cloud

Radu B Rusu
Administrator
How do you remove the NAN points? Using PCL functions or your own code?

Please remember that you need to set the width and the height of the data accordingly after NAN removal (usually width =
cloud.points.size () and height = 1) in order for the viewer to display your data correctly.

Cheers,
Radu.

On 06/17/2012 12:52 PM, Eduardo Fernandez wrote:
> Ken, many thanks for your reply,
>
> actually I made I mistake when copying the example here, in my code I was
> passing a pointer to the CloudViewer (as you say)
>
>   pcl::PointCloud<pcl::PointXYZRGBA>::Ptr copyPointCloudPtr(new
> pcl::PointCloud<pcl::PointXYZRGBA>  );
>
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: CloudViewer doesn't display correctly an organized point cloud

Eduardo Fernandez
This post was updated on .
Hi Radu,

Thanks for your reply. I've figured out why the visualization went wrong, I
was already setting width and height in my cloud, but I had to set
"is_dense" to "false" when I was keeping the NAN points (which is the case
where my visualization failed):

downsampledPointCloudPtr->is_dense = false;

Thanks,
Edu Fdez
Reply | Threaded
Open this post in threaded view
|

Re: CloudViewer doesn't display correctly an organized point cloud

rinoa
In reply to this post by Radu B Rusu
CONTENTS DELETED
The author has deleted this message.