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 8291649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:12:18+00:00 2026-06-08T13:12:18+00:00

Using Point Cloud Library on Ubuntu, I am trying to take multiple point clouds

  • 0

Using Point Cloud Library on Ubuntu, I am trying to take multiple point clouds from the Kinect and store them in memory for later use in the program. My code shown at the bottom of this post is designed to store the first Point Cloud from the Kinect and output its width and height. The program gives me a runtime error:

/usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr<T>::operator->() const [with T = pcl::PointCloud<pcl::PointXYZ>]: Assertion `px != 0' failed.

All help is greatly appreciated and I always accept an answer!

The code:

  #include <pcl/io/openni_grabber.h>
  #include <pcl/visualization/cloud_viewer.h>

 class SimpleOpenNIViewer
 {
  public:
  SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}

 pcl::PointCloud<pcl::PointXYZ>::Ptr prevCloud;


  void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud)
  {


if (!viewer.wasStopped())
   viewer.showCloud (cloud);


//ICP start
if(!prevCloud) {
    pcl::PointCloud<pcl::PointXYZ>::Ptr prevCloud( new pcl::PointCloud<pcl::PointXYZ>());

    pcl::copyPointCloud<pcl::PointXYZ, pcl::PointXYZ>(*cloud, *prevCloud);
}

cout << prevCloud->width << " by " << prevCloud->height << endl; 



  }

  void run ()
  {
    pcl::Grabber* interface = new pcl::OpenNIGrabber();

    boost::function<void (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr&)> f =
      boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);


    interface->registerCallback (f);

    interface->start ();


    while (!viewer.wasStopped())
    {
      boost::this_thread::sleep (boost::posix_time::seconds (1));
    }

    interface->stop ();
  }

  pcl::visualization::CloudViewer viewer;
 };

  int main ()
{
 SimpleOpenNIViewer 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-08T13:12:19+00:00Added an answer on June 8, 2026 at 1:12 pm

    Try this, I don’t have the Kinect drivers installed so I can’t test. Basically in my version prevCloud is instantiated in the constructor so (!prevCloud) will always equal ‘false’. Which is to say prevCloud.get() != NULL.

    #include <pcl/io/openni_grabber.h>
    #include <pcl/visualization/cloud_viewer.h>
    
    class SimpleOpenNIViewer
    {
    typedef pcl::PointXYZ                           Point;
    typedef pcl::PointCloud<Point>                  PointCloud;
    public:
    SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {
            prevCloud = PointCloud::Ptr(NULL);
        }
    
    void cloud_cb_ (const PointCloud::ConstPtr &cloud)
    {
        if (!viewer.wasStopped())
            viewer.showCloud (cloud);
                if (!prevCloud) // init previous cloud if first frame
                        prevCloud = PointCloud::Ptr(new PointCloud);
                else.   // else RunICP between cloud and prevCloud
                        //RunICP(cloud,prevCloud);
    
                //Copy new frame in to prevCloud
        pcl::copyPointCloud<Point, Point>(*cloud, *prevCloud);
        cout << prevCloud->width << " by " << prevCloud->height << endl; 
    }
    
    void run ()
    {
        pcl::Grabber* interface = new pcl::OpenNIGrabber();
    
        boost::function<void (const PointCloud::ConstPtr&)> f =
        boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);
    
        interface->registerCallback (f);
        interface->start ();
    
    
        while (!viewer.wasStopped())
        {
            boost::this_thread::sleep (boost::posix_time::seconds (1));
        }
    
        interface->stop ();
    }
    
    PointCloud::Ptr prevCloud;
    pcl::visualization::CloudViewer viewer;
    };
    
    int main ()
    {
    SimpleOpenNIViewer v;
    v.run ();
    return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a test project using the Point Cloud Library and
I'm trying to output realtime 3D point clouds (307,200 points) using XNA and Kinect;
I have a cloud point obtained from photogrammetry from a person's back. I'm trying
I'm using processing in conjunction with the kinect to capture point cloud data. My
Using Android opengl I need to move an object from point A to point
So i'm trying to move my application to the cloud, specifically im using RackSpace
I need to visualize 3D point clouds using C++, I started learning OpenGL but
I'm using the Microsoft Kinect SDK to get the depth and color information from
I'm running python 2.4 from cgi and I'm trying to upload to a cloud
Background: I am trying to animate a rotating 3D scatter plot using R's lattice::cloud()

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.