ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

PCD viewer problem for Object Detection using Kinect

asked 2012-02-23 06:49:48 -0500

PriyankaP gravatar image

updated 2016-10-24 09:10:54 -0500

ngrennan gravatar image

I am working on object detection using ROS-PCL. Using a Kinect camera I save point clouds generated by the following code in a .pcd file. My problem is that I am unable to see the object as a point cloud in the PCD file viewer. Is the code a problem? It generates a PCD file but I do not know if it works on giving a proper point cloud in .pcd. I just obtain a straight line of points in the middle of the PCD viewer for all objects. Please help.

#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <boost/foreach.hpp>

pcl::PointCloud<pcl::PointXYZRGB> PC;    

void callback(const sensor_msgs::PointCloud2ConstPtr& msg)
     printf("Writing the file...\n");
     pcl::fromROSMsg(*msg, PC);
     int a = pcl::io::savePCDFileBinary"/home/rootx/pcl_proj/pcd/temp.pcd", PC);
     printf("Saved the pcd file...%d Return %d\n", PC.points.size(), a);


int main(int argc, char** argv)
     ros::init(argc, argv, "sub_pcl");
     ros::NodeHandle nh;
     ros::Subscriber sub = nh.subscrib<sensor_msgs::PointCloud2>("points2", 1, callback);

I tried this command to view pcd file pcd_viewer: rosrun perception_pcl pcd_viewer "filename"

Edit: Using pcl::PointCloud<pcl::pointxyzrgba> PC; instead of the statement used in the code, as suggested, gives an error: terminate called after throwing an instance of 'pcl::InvalidConversionException' what(): Failed to find a field named: 'rgba'. Cannot convert message to PCL type. Aborted.

Does it need a header file I haven't added perhaps?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-02-23 09:05:20 -0500

makokal gravatar image

You should probably have

pcl::PointCloud<pcl::PointXYZRGBA> PC;

instead of what you have there.

edit flag offensive delete link more

Question Tools


Asked: 2012-02-23 06:49:48 -0500

Seen: 1,388 times

Last updated: Feb 28 '12