Monday, December 2, 2013

Step 3: Moving the Kinect Motor & Saving Point Clouds to a file using the Microsoft Kinect

Through hours and testing and experimentation, I have come to find out that I can get the Kinect motor to move using the libfreenect library and save point clouds to a file using the OpenNI and PCL libraries. I also found out out that the way to achieve this is very brute force and is a bit inconsistent.

The steps are:

1. Move the Kinect motor to the appropriate angle

2. Save the point cloud to file (run this code 2-3 times to ensure that the connection is established between the OpenNI/PCL code and the Kinect)


The reason that the OpenNI/PCL code does not establish a connection with the Kinect has to do with the signal:

// make callback function from member function
        boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
        boost::bind (&OpenNISaveFrame::save, 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 ();

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


If the Kinect already has an established signal (which is does with the libfreenect library) the connection never registers a callback to the function, which causes the save function in my code not to be executed. Through testing, I have found out that the execution of the save code multiple times (at least 2-3 times) guarantees that the save function is called at least once. I need to test this more to see why that is the case, but, for now,  I can take point clouds from the environment at different angles using the Kinect.

No comments:

Post a Comment