0
$\begingroup$

Rosanswers logo

I am trying to visualize point cloud, but it gave error like error C2664: 'void pcl::visualization::CloudViewer::showCloud(const boost::shared_ptr &,const std::string &)' : cannot convert parameter 1 from 'pcl::PointCloud' to 'const boost::shared_ptr &'. Thanks in advance.

Here is my sample code:

#include <iostream>

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/visualization/cloud_viewer.h>

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

  // Fill in the cloud data 
  cloud.width    = 5; 
  cloud.height   = 1; 
  cloud.is_dense = false; 
  cloud.points.resize (cloud.width * cloud.height); 

  for (size_t i = 0; i < cloud.points.size (); ++i) 
  { 
    cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f); 
    cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f); 
    cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f); 
  } 

  pcl::visualization::CloudViewer viewer ("Simple Cloud Viewer"); 
  viewer.showCloud (cloud); 

  while (!viewer.wasStopped ()) 
  { 
  } 

  return (0); 
}

Originally posted by Nihad on ROS Answers with karma: 22 on 2013-05-01

Post score: 0


Original comments

Comment by Nihad on 2013-05-02:
Thnx. It works fine.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Try "viewer.showCloud(cloud.makeShared());"


Originally posted by Felix Endres with karma: 6468 on 2013-05-02

This answer was ACCEPTED on the original site

Post score: 5

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.