Wednesday, November 27, 2013

Step 2: Save a Point Cloud from a Kinect

Because the Point Cloud Library website provides an easy implementation for saving point clouds to a file, which can be found here, creating a class for to accomplish this was very trivial. In my project, I call this class OpenNISaveFrame, which saves the point cloud captured by the Kinect into a binary compressed format and as a .pcd (Point Cloud Data) file.

The part of this step that was not trivial was trying to combine these two classes into one workable program that can be implemented rather quickly. My first attempts at this have fail as the libreenect and OpenNI "fight" over control of the Kinect with their function calls. More technically, when the program wants to move the Kinect's motor, the code establishes a signal to the Kinect in the code via libfreenect functions and moves the Kinect accordingly. If the program wants to save point clouds from the Kinect, the code establishes a different connection via PCL and OpenNI functions and the Kinect responds to that signal accordingly. The problem occurs when both connections are being established in the same program. One of two different complications occurred while testing this problem:

  - The libfreenect connection is established, but the OpenNI/PCL connection throws an Exception as the OpenNI/PCL cannot establish a connection with the Kinect since the libfreenect connection is still sending signals to the Kinect, causing the program to end prematurely.

- The libfreenect connection is established and manually shutdown by the code, which causes a segmentation fault to occur in the program.

Since I believe there is a way to get this two libraries to work concurrently in the same program. I will continue to experiment with the classes and the program and will update this blog accordingly.

*** Update: through more testing, I have come to find out that freenect_sync.h and freenect_sync.c provide a disconnection in the thread between the signal and the Kinect. I need to create a class and immediately implement it. (12/1/13) ***

No comments:

Post a Comment