removeNaNFromPointCloud does not seem to work

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

removeNaNFromPointCloud does not seem to work

baggepinnen
I seem to have a lot of problems with NaNs in my point clouds. I would like the following code to help me get rid of those NaNs, but it doesn't

surface->is_dense = 0;
std::vector<int> indices;
pcl::removeNaNFromPointCloud(*surface, *cloud_out, indices);

By halting in the debugger I can conclude that the cloud surface has a lot of points but the cloud cloud_out has zero points after the function call.

A call likeĀ 
pcl::removeNaNFromPointCloud(*surface,*surface, indices);
Will leave the surface cloud untouched and the vector of indices as long as the number of points in the cloud.

Also, the indices returned are in a std::vector<int>, all PCL methods however require indices to be passed as a special PCL type, why the inconsistency?

Any suggestions on what I might be doing wrong?

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: removeNaNFromPointCloud does not seem to work

nishant
This post has NOT been accepted by the mailing list yet.
#include <iostream>
#include <limits>
#include<conio.h>

// PCL
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/filter.h>

int
main (int, char**)
{
        //define the cloud type
  typedef pcl::PointCloud<pcl::PointXYZ> CloudType;
  //declare a pointer of pointcloud and initialize it using new
  CloudType::Ptr cloud (new CloudType);
  //set the member of point cloud dense to be false
  cloud->is_dense = false;

  //create another point cloud
  CloudType::Ptr output_cloud (new CloudType);

  //Create  a point type and initialize it with nan
  CloudType::PointType p_nan;
  p_nan.x = std::numeric_limits<float>::quiet_NaN();
  p_nan.y = std::numeric_limits<float>::quiet_NaN();
  p_nan.z = std::numeric_limits<float>::quiet_NaN();

  //load the pointtype in pointcloud - cloud
  cloud->push_back(p_nan);

  //Create a valid point type and push that also in cloud
  CloudType::PointType p_valid;
  p_valid.x = 1.0f;
  cloud->push_back(p_valid);

  std::cout << "size: " << cloud->points.size () << std::endl;

  std::vector<int> indices;
  pcl::removeNaNFromPointCloud(*cloud, *output_cloud, indices);
  std::cout << "size: " << output_cloud->points.size () << std::endl;
  getch();

  return 0;
}
try this one to understand.we add two point to the cloud-one is nan and other is p_valid.at the end i get only p_valid.It works even getting cloud from kinnect and removing nan.
Reply | Threaded
Open this post in threaded view
|

Re: removeNaNFromPointCloud does not seem to work

aichim
Administrator
In reply to this post by baggepinnen
Hi,

See below.


On Feb 5, 2013, at 12:43 AM, Fredrik Bagge Carlson <[hidden email]> wrote:

I seem to have a lot of problems with NaNs in my point clouds. I would like the following code to help me get rid of those NaNs, but it doesn't

surface->is_dense = 0;
std::vector<int> indices;
pcl::removeNaNFromPointCloud(*surface, *cloud_out, indices);

By halting in the debugger I can conclude that the cloud surface has a lot of points but the cloud cloud_out has zero points after the function call.

A call like 
pcl::removeNaNFromPointCloud(*surface,*surface, indices);
Will leave the surface cloud untouched and the vector of indices as long as the number of points in the cloud.

It just simply means that you have no NaNs in your cloud. If you are not convinced, manually go through each point of your cloud in a for loop and count how many times !pcl_isfinite (surface->points[i].x/y/z) is true.


Also, the indices returned are in a std::vector<int>, all PCL methods however require indices to be passed as a special PCL type, why the inconsistency?

The "special" PCL structure your are talking about is a pcl::IndicesPtr which is simply a typedef for boost::shared_ptr<std::vector<int> >. The documentation is your friend. :-)


Any suggestions on what I might be doing wrong?
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: removeNaNFromPointCloud does not seem to work

amitshri
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: removeNaNFromPointCloud does not seem to work

Christian Potthast
Amitshri,

that is correct, after using the function removeNaNFromPointCloud the pc is not organize anymore.

You can not retain the structure using the above mentioned function, since the points are removed from the pc. If you need to retain the structure, iterate over the point cloud and check for NaN's, only process the points which are valid.

Cheers
Chris

On Apr 6, 2013, at 8:46 AM, amitshri wrote:

> removeNaNFromPointCloud converts an organized Point Cloud into non organized
> one?
>
> How can I retain the structure of Point Cloud after applying remove NaN
> filter?
>
>
>
> --
> View this message in context: http://www.pcl-users.org/removeNaNFromPointCloud-does-not-seem-to-work-tp4025886p4027102.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: removeNaNFromPointCloud does not seem to work

mark_vision
In my case the two clouds are not empty. I save the results of the function on two pcd ASCII files and what I get is two identical files. So the function really does nothing.

A clue may be the fact that in the clouds I see "nan" values instead of "NaN".

Any suggestion?

I use PCL 1.7.0
Reply | Threaded
Open this post in threaded view
|

Re: removeNaNFromPointCloud does not seem to work

Ber461
This post was updated on .
Why don't you try using a text editor's Find and Replace feature, to change all instances of "nan" to "NaN"?