create an array of PointCloudXYZRGB

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

create an array of PointCloudXYZRGB

sha
Hi

I want to dynamically create an array of boost shared pointers of PointCloudXYZRGB that should take dynamically created point clouds. So its like my clustering algorithm gives me some 'x' clouds at runtime and i want to create an array/list of them and use them for publishing later.

 I am not able to successfully create and use them for publishing.


Regards
sha
Thanks sha
Reply | Threaded
Open this post in threaded view
|

Re: create an array of PointCloudXYZRGB

Radu B. Rusu
Administrator
And how would you like the community to help you? :) Please post a code snippet and be more specific with your problem,
otherwise you risk at our colleagues ignoring your e-mail.

Cheers,
Radu.
--
http://pointclouds.org

On 11/07/2011 12:09 AM, sha wrote:

> Hi
>
> I want to dynamically create an array of boost shared pointers of
> PointCloudXYZRGB that should take dynamically created point clouds. So its
> like my clustering algorithm gives me some 'x' clouds at runtime and i want
> to create an array/list of them and use them for publishing later.
>
>  I am not able to successfully create and use them for publishing.
>
>
> Regards
> sha
>
> -----
> Thanks
> sha
> --
> View this message in context: http://www.pcl-users.org/create-an-array-of-PointCloudXYZRGB-tp3486350p3486350.html
> Sent from the Point Cloud Library (PCL) Users 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
sha
Reply | Threaded
Open this post in threaded view
|

Re: create an array of PointCloudXYZRGB

sha
Thanks Radu for pointing this out else this thread would have made the way to archives pretty early :)  Here it is :

I tried with these ways


// trial one
  pcl::PointCloud<pcl::PointXYZRGB>::Ptr **cloud_clusters_ptr;

  for (int i=0; i<=numClusters; i++) {
    cloud_clusters_ptr[i] = new pcl::PointCloud<pcl::PointXYZRGB>::Ptr (new pcl::PointCloud<pcl::PointXYZRGB>);
  }

  // trial two

  pcl::PointCloud<pcl::PointXYZRGB>::Ptr *cloud_clusters = new pcl::PointCloud<pcl::PointXYZRGB>::Ptr (new pcl::PointCloud<pcl::PointXYZRGB>) [numClusters];
Thanks sha
Reply | Threaded
Open this post in threaded view
|

Re: create an array of PointCloudXYZRGB

Radu B. Rusu
Administrator
As many have pointed in the past, please do not use pointers to boost::shared_ptr. Not only that it is confusing, but
you risk at getting a variety of interesting errors later in your code.

If you REALLY want to create an array of PointCloud::Ptr, use standard containers like std::vector.

Cheers,
Radu.
--
http://pointclouds.org

On 11/07/2011 12:28 AM, sha wrote:

> Thanks Radu for pointing this out else this thread would have made the way to
> archives pretty early :)  Here it is :
>
> I tried with these ways
>
>
> // trial one
>   pcl::PointCloud<pcl::PointXYZRGB>::Ptr **cloud_clusters_ptr;
>
>   for (int i=0; i<=numClusters; i++) {
>     cloud_clusters_ptr[i] = new pcl::PointCloud<pcl::PointXYZRGB>::Ptr (new
> pcl::PointCloud<pcl::PointXYZRGB>);
>   }
>
>   // trial two
>
>   pcl::PointCloud<pcl::PointXYZRGB>::Ptr *cloud_clusters = new
> pcl::PointCloud<pcl::PointXYZRGB>::Ptr (new
> pcl::PointCloud<pcl::PointXYZRGB>) [numClusters];
>
>
> -----
> Thanks
> sha
> --
> View this message in context: http://www.pcl-users.org/create-an-array-of-PointCloudXYZRGB-tp3486350p3486376.html
> Sent from the Point Cloud Library (PCL) Users 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: create an array of PointCloudXYZRGB

Ryosuke
Dear all,

Regarding this issue, I have the same problem.
I tried the vector, and the build has passed, but the execution error has occurred.
This error says "R6010 - abort() has been called." Also, Command prompt shows "Assertion failed: px !=0, file C:\Program Files\Boost\include\boost\smart_ptr\shared_ptr.hpp, line 424".
Although I checked this line, I can't understand what is written.

Could you tell me how I can fix it?
My code is the following, and the error occurs at the last line "cloud_clusters_ptr[0]->points.size()".
Could you tell me how I should access each poindcloud of the vector?

std::vector< pcl::PointCloud<PointType>::Ptr, Eigen::aligned_allocator <pcl::PointCloud <PointType>::Ptr > > cloud_clusters_ptr (NumberOfModels);
for (int i = 0; i < NumberOfModels; ++i )
{
        pcl::PointCloud<PointType>::Ptr cloud (new pcl::PointCloud<PointType>);
        pcl::io::loadPCDFile (load_file[i], *cloud );
        cloud_clusters_ptr.push_back(cloud);
}
std::cout << cloud_clusters_ptr[0]->points.size() << std::endl;

Thank you in advance.
Ryosuke
Reply | Threaded
Open this post in threaded view
|

Re: create an array of PointCloudXYZRGB

VictorLamoine
Administrator
Hello,

Assertion failed: px !=0 means you are trying to access to an un-initialized pointer:
http://stackoverflow.com/questions/3541179/shared-ptr-assertion-px-0-failed

Bye