Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:23:08+00:00 2026-06-13T06:23:08+00:00

This is what I have so far and I want to save pcd file

  • 0

This is what I have so far and I want to save pcd file from it
I know I have to do something like this but not exactly sure
pcl::PointCloud::PointPointXYZRGBA> cloud;
pcl::io:;savePCDFileASCII(“test.pcd”,cloud);

what do i have to add in my current code that i will have test.pcd
Thanks

    #include <pcl/point_cloud.h>
    #include <pcl/point_types.h>
    #include <pcl/io/openni_grabber.h>
    #include <pcl/visualization/cloud_viewer.h>
    #include <pcl/common/time.h>

    class SimpleOpenNIProcessor
    {
        public:
            SimpleOpenNIProcessor () : viewer ("PCL OpenNI Viewer") {}
            void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
            {
                static unsigned count = 0;
                static double last = pcl::getTime ();
                if (++count == 30)
                {
                    double now = pcl::getTime ();
                    std::cout << "distance of center pixel :" << cloud->points [(cloud->width >> 1) * (cloud->height + 1)].z << " mm. Average framerate: " << double(count)/double(now - last) << " Hz" <<  std::endl;
                    count = 0;
                    last = now;
                }
                if (!viewer.wasStopped())
                    viewer.showCloud (cloud);
            }

            void run ()
            {
                // create a new grabber for OpenNI devices
                pcl::Grabber* interface = new pcl::OpenNIGrabber();

                // make callback function from member function
                boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
                    boost::bind (&SimpleOpenNIProcessor::cloud_cb_, this, _1);

                // connect callback function for desired signal. In this case its a point cloud with color values
                boost::signals2::connection c = interface->registerCallback (f);

                // start receiving point clouds
                interface->start ();

                // wait until user quits program with Ctrl-C, but no busy-waiting -> sleep (1);
                while (true)
                    boost::this_thread::sleep (boost::posix_time::seconds (1));

                // stop the grabber
                interface->stop ();
            }

            pcl::visualization::CloudViewer viewer;
    };

    int main ()
    {
      SimpleOpenNIProcessor v;
      v.run ();
      return (0);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:23:09+00:00Added an answer on June 13, 2026 at 6:23 am
    #include <iostream>
    #include <string>
    #include <sstream>
    
    #include <pcl/io/pcd_io.h>
    #include <pcl/point_types.h>
    #include <pcl/io/openni_grabber.h>
    #include <pcl/visualization/cloud_viewer.h>
    
    using namespace std; 
    
    const string OUT_DIR = "D:\\frame_saver_output\\"; 
    
    class SimpleOpenNIViewer 
    { 
    public: 
        SimpleOpenNIViewer () : viewer ("PCL Viewer") 
        { 
                    frames_saved = 0; 
                    save_one = false; 
        } 
    
        void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud) 
        { 
                    if (!viewer.wasStopped()) { 
                            viewer.showCloud (cloud); 
    
                            if( save_one ) { 
                                    save_one = false; 
                                    std::stringstream out; 
                                    out << frames_saved; 
                                    std::string name = OUT_DIR + "cloud" + out.str() + ".pcd"; 
                                    pcl::io::savePCDFileASCII( name, *cloud ); 
                            } 
                    } 
        } 
    
        void run () 
        { 
                    pcl::Grabber* interface = new pcl::OpenNIGrabber(); 
    
                    boost::function<void (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&)> f = 
                            boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1); 
    
                    interface->registerCallback (f); 
    
                    interface->start (); 
    
                    char c; 
    
                    while (!viewer.wasStopped()) 
                    { 
                            //sleep (1); 
    
                            c = getchar(); 
                            if( c == 's' ) { 
                                    cout << "Saving frame " << frames_saved << ".\n"; 
                                    frames_saved++; 
                                    save_one = true; 
                            } 
                    } 
    
                    interface->stop (); 
            } 
    
            pcl::visualization::CloudViewer viewer; 
    
            private: 
                    int frames_saved; 
                    bool save_one; 
    
    }; 
    
    int main () 
    { 
        SimpleOpenNIViewer v; 
        v.run (); 
        return 0; 
    } 
    

    Here you go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this so far but the Column 'name' is ambiguous, so I want
I have this so far but I don't know how to write over the
I have this so far: http://jsfiddle.net/u5vhS/54/ . What I want to be able to
Thanks to everyone out there helping newbies like me. So far I have this:
I have this code so far which perfectly but relies on there being a
I have a text file that looks like this: STUFF UP HERE APEXED NUMBER
I have this so far on one of my programs and I would like
Trying to create a transparent gif with PIL. So far I have this: from
So far i have this: mov ah,02h mov cl,11001100001111011101000b ;6,692,584 in dec mov dl,0
I'm using the javascript module pattern, and have this so far: var APP; if(APP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.