Ask Your Question
0

How to open PCD file

asked 2016-03-08 05:47:08 -0500

kalum gravatar image

Hi guys. I'm working with my kinect to extract point clouds. So I run at first openni_launch and after i run : rosrun pcl_ros pointcloud_to_pcd input:=/camera/depth_registered/points So after this, ROS saves every point clouds that kinect gets. SO my question is: how can I extract data from a PCD? I want to extract fields about sensor_msgs/PointField[]. It exists another method to get every information about a PCD file? thanks to all!

edit retag flag offensive close merge delete

Comments

If you installed pcl library you can use

#include <pcl/io/pcd_io.h>

otherwise use

#include <pcl_ros/io/pcd_io.h>

with the following command

pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud)
Reza1984 gravatar image Reza1984  ( 2016-03-09 01:44:27 -0500 )edit

Thanks man!! I've another question. Is there a method to discover the distance between my image/object and my kinect? Thank you :)

kalum gravatar image kalum  ( 2016-03-10 05:11:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-03-09 01:16:54 -0500

Akif gravatar image

You can use PCL. Check this tutorial; http://pointclouds.org/documentation/...

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

int
main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

  if (pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud) == -1) //* load the file
  {
    PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
    return (-1);
  }
  std::cout << "Loaded "
            << cloud->width * cloud->height
            << " data points from test_pcd.pcd with the following fields: "
            << std::endl;
  for (size_t i = 0; i < cloud->points.size (); ++i)
    std::cout << "    " << cloud->points[i].x
              << " "    << cloud->points[i].y
              << " "    << cloud->points[i].z << std::endl;

  return (0);
}
edit flag offensive delete link more

Comments

Thanks man!! I've another question. Is there a method to discover the distance between my image/object and my kinect? Thank you :)

kalum gravatar image kalum  ( 2016-03-10 05:11:40 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-03-08 05:47:08 -0500

Seen: 3,088 times

Last updated: Mar 09 '16