How can i visualize point cloud with pcl?
Hi, I'm trying to use pcl (Point Cloud Library) with ros, and I've done working on tutorial. However when I try to visualize point cloud, I got error saying "undefined reference to `pcl::visualization::CloudViewer::CloudViewer()' " even though my code did work without ros environment.
Here is my code. I just want to visualize my points with pcl::visualization::CloudViewer
command. How can i fix it? Thanks in advance.
# include <ros/ros.h>
# include <pcl_ros/point_cloud.h>
# include <pcl/point_types.h>
# include <boost/foreach.hpp>
#include <pcl/visualization/cloud_viewer.h>
typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloud;
void callback(const PointCloud::ConstPtr& msg){
printf("Cloud: width= %d, height= %d \n", msg->width, msg->height);
BOOST_FOREACH(const pcl::PointXYZRGB& pt, msg->points)
printf("\t(%f, %f, %f)\n", pt.x, pt.y, pt.z);
// create viewer
pcl::visualization::CloudViewer viewer("PointCloudViewer");
viewer.showCloud(msg);
}
int main(int argc, char** argv) {
ros::init (argc, argv, "show_pcl");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe<PointCloud>("/camera/depth/color/points",1,callback);
ros::spin();
}