issues with classes, pointers..in practicles examples

Hi all,
I'm a beginner in programming with C++. I followed your well done tutorial some months ago. But now I'm practising on a real case.
I want to develop something using PCL 1.6.

Up to now I had some troubles but I solved them.

I want to go over the only tutorials provided about point cloud library.
I started from this tutorial: http://pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber

I set all the code in well done files header, cpp, etc.. as explained in your tutorial. Up to here all ok.

I want to get a point cloud in a specific frame to use for other things, for example saving in a file, but at the same time viewing the streaming on screen

My file.h is
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  class NIViewer
 {
	public:

     NIViewer (int,int);
     void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud);   
     void run (); 

	 
	 const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr *cloudframe;
	 

	 
     pcl::visualization::CloudViewer viewer;
 };


My file.cpp for class definition has this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
NIViewer::NIViewer (void)
	{
		cloudframe=new pcl::PointCloud<pcl::PointXYZRGBA>;
	}
void NIViewer::run ()
     {
       pcl::Grabber* interface = new pcl::OpenNIGrabber();

       boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f = boost::bind (&NIViewer::cloud_cb_, this, _1);
       interface->registerCallback (f);

       interface->start ();

       
	   while (!viewer.wasStopped())
		   {
			 boost::this_thread::sleep (boost::posix_time::seconds (1));
			 for(int i=1;i<=30;++i)
				{
				 if(i==30)
					 {
						char j=(char)i;
						std::string name=IND+"cloud"+j+ ".pcd";
						pcl::io::savePCDFileASCII(name,*cloudframe);
						cout<<"\nFile saved!!\n";
					 }
				}
		   }

       interface->stop ();
	   //&nuvola=&cloud;
     }

void NIViewer::cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
     {
       if (!viewer.wasStopped())
         viewer.showCloud (cloud);
	   cloudframe=&cloud;
     }


IND is a constant string.

NIViewer is the constructor of the class, cloudframe is a pointer.
All doesn't work.

VS2010 says that 'NIViewer' is a no appropriate default constructor available and that 'NIViewer::NIViewer(void)' : overloaded member function not found in 'NIViewer'

Moreover it finds an error in lines:
pcl::io::savePCDFileASCII(name,*cloudframe);
If cloudframe is a pointer, why is it wrong?
That is: error C2784: 'int pcl::io::savePCDFileASCII(const std::string &,const pcl::PointCloud<PointT> &)' : could not deduce template argument for 'const pcl::PointCloud<PointT> &' from 'boost::shared_ptr<T>' C:\...\..\Viewer.cpp


Could you help me to understand why there are some errors, how to solve it, and how to get better work using this documentation: http://docs.pointclouds.org/1.6.0/group__io.html#ga09bdff6c474655ebbefa8a97de669ece

Thank you very much in advance!

I don't know much about this. I probably should read more on namespaces but I wonder if you need to do something like this for the constructor.

void NIViewer::NIViewer::cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)


I just found this here

http://www.cplusplus.com/forum/articles/10627/


I think i'll read that tomorrow.
Last edited on
I've not exactly understood which row reports your suggestion.

Anyway it doesn't work!

Other suggestions?
Topic archived. No new replies allowed.