Writing a loadCloud subfunction

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

Writing a loadCloud subfunction

Wyllich
Hello,

I wanted o write simply a function which would load a cloud and return a pointer to it.
However, I'm facing a problem I do no know the solution of, when I use KFLANN to generate the kdtree.

Here's the code:

pcl::PointCloud<pcl::PointXYZ>::Ptr loadCloud(char* cloudfile)
{
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZL>);
    if(pcl::io::loadPCDFile<pcl::PointXYZ>(cloudfile, *cloud)==-1)
    {
        PCL_ERROR ("Error while reading file. \n");
    }
    return cloud;
}

Then, in another function, I would have:

  pcl::PointCloud<pcl::PointXYZL>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZL>);
  cloud = loadCloud(cloudfile);
 
  pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
  kdtree.setInputCloud(cloud);

...

thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Writing a loadCloud subfunction

vs-tec
Hello,

check your point type: sometimes you have pcl::PointXYZ and in other
cases pcl::PointXYZL.

V


On 28.08.2017 10:13, Wyllich wrote:

> Hello,
>
> I wanted o write simply a function which would load a cloud and return a
> pointer to it.
> However, I'm facing a problem I do no know the solution of, when I use
> KFLANN to generate the kdtree.
>
> Here's the code:
>
> pcl::PointCloud<pcl::PointXYZ>::Ptr loadCloud(char* cloudfile)
> {
>      pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new
> pcl::PointCloud<pcl::PointXYZL>);
>      if(pcl::io::loadPCDFile<pcl::PointXYZ>(cloudfile, *cloud)==-1)
>      {
>          PCL_ERROR ("Error while reading file. \n");
>      }
>      return cloud;
> }
>
> Then, in another function, I would have:
>
>    pcl::PointCloud<pcl::PointXYZL>::Ptr cloud (new
> pcl::PointCloud<pcl::PointXYZL>);
>    cloud = loadCloud(cloudfile);
>  
>    pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;
>    kdtree.setInputCloud(cloud);
>
> ...
>
> thanks in advance.
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Writing-a-loadCloud-subfunction-tp4044985.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

--
___________________________________________________________
Senior Developer

Tau Epsilon C GmbH & Co. KG
Viktor Seib
Universitätsstraße 3
56070 Koblenz

fon: +49 261 45093140
fax: +49 261 45093149

mail:   [hidden email]
web:    www.tau-epsilon-c.com

Geschäftsführer: Andreas Rieser

Rechtsform GmbH & Co. KG - Sitz: Koblenz
Registergericht: Amtsgericht Koblenz HRA 21384

Persönlich haftende Gesellschafterin: Tau Epsilon C Verwaltungs GmbH
Rechtsform GmbH - Sitz: Koblenz
Registergericht: Amtsgericht Koblenz HRB 24137

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error) please notify
the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.

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

Re: Writing a loadCloud subfunction

Wyllich
Thanks for the help.

It is working now. I should be more careful.