Output format of pcl::io::saveVTKFile() ?

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

Output format of pcl::io::saveVTKFile() ?

George Bora
Hello I have a project which requires me to convert a pointcloud saved in a pcd file to vtk points for which I wrote the following code:

// STL
#include <iostream>

// PCL
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int
main (int argc, char** argv)
{
  sensor_msgs::PointCloud2 cloud_blob;

  if (pcl::io::loadPCDFile ("test_pcd.pcd", cloud_blob) == -1) //* load the file
  {
    PCL_ERROR ("Couldn't read file  \n");
    return (-1);
  }
  std::cout << "Loaded the file."
            << std::endl;
 
  if (pcl::io::saveVTKFile ("cloud.vtk", cloud_blob) == -1) //* load the file
    {
      PCL_ERROR ("Couldn't convert the file \n");
      return (-1);
    }
    std::cout << "Saved as VTK."
              << std::endl;
 return (0);
}

The code itself runs, but I couldn't find in the documentation exactly in which format the new file is created.

I understand this is not a pcl question persay, but as PCL uses VTK I think I will have better luck here to find people who know both pcl and vtk.

I need more information about the exact format because from my newcomer understanding of VTK there are multiple formats which are or where supported , the link is to the Python tutorials as I must use the Python wrappings so if you have any advice about the format or which reader to use if your examples can be in Python  it would be heavenly.
Reply | Threaded
Open this post in threaded view
|

Re: Output format of pcl::io::saveVTKFile() ?

aichim
Administrator
Hi,

The name of the functions in the pcl_io module all mention the output file format: saveXYZFile => my_cloud.xyz

In your case, it will save a .vtk file. You can find the whole format specification here: http://www.visitusers.org/index.php?title=ASCII_VTK_Files or here http://www.vtk.org/VTK/img/file-formats.pdf

Cheers,
Alex
---
http://www.openperception.org



On Feb 2, 2013, at 1:29 PM, George Bora <[hidden email]> wrote:

> Hello I have a project which requires me to convert a pointcloud saved in a
> pcd file to vtk points for which I wrote the following code:
>
> // STL
> #include <iostream>
>
> // PCL
> #include <pcl/io/pcd_io.h>
> #include <pcl/point_types.h>
>
> int
> main (int argc, char** argv)
> {
>  sensor_msgs::PointCloud2 cloud_blob;
>
>  if (pcl::io::loadPCDFile ("test_pcd.pcd", cloud_blob) == -1) //* load the
> file
>  {
>    PCL_ERROR ("Couldn't read file  \n");
>    return (-1);
>  }
>  std::cout << "Loaded the file."
>            << std::endl;
>
>  if (pcl::io::saveVTKFile ("cloud.vtk", cloud_blob) == -1) //* load the
> file
>    {
>      PCL_ERROR ("Couldn't convert the file \n");
>      return (-1);
>    }
>    std::cout << "Saved as VTK."
>              << std::endl;
> return (0);
> }
>
> The code itself runs, but I couldn't find in the documentation exactly in
> which format the new file is created.
>
> I understand this is not a pcl question persay, but as PCL uses VTK I think
> I will have better luck here to find people who know both pcl and vtk.
>
> I need more information about the exact format because from my newcomer
> understanding of VTK there are multiple formats  which are or where
> supported <http://www.vtk.org/Wiki/VTK/Examples/Python#Input>   , the link
> is to the Python tutorials as I must use the Python wrappings so if you have
> any advice about the format or which reader to use if your examples can be
> in Python  it would be heavenly.
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Output-format-of-pcl-io-saveVTKFile-tp4025829.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: Output format of pcl::io::saveVTKFile() ?

George Bora
Thank you for the info it is indeed as you say the legacy vtk format, I found it out via trial and error and some help from the vtk forums which suggested a vtkPolyData reader for this file formerly known as pcd.