Monday, March 5, 2012

Recording Image/Video from a Kinect using PCL

I wanted to record some images and videos from my Kinect sensor Here's an easy way to do it.

I tried getting a demo together based on the OpenNI examples and the ofxOpenNI examples, which was a rough start. It turns out the PCL project has a much wider array of useful examples, and in my opinion it is just much better.



You will need:
  •  Ubuntu 11.04 Linux (PCL supports Windows and MacOSX, but my instructions do not) 
  • A Microsoft Kinect sensor (~$200 at your local vidoe game store) 
Steps:
  • download and compile PCL from source http://pointclouds.org/downloads/ 
  • open up the folder "PCL-1.5.1-Source/build/bin" in a terminal window 
  • run command "./openni_save_image", do a silly dance in front of the camera, and press ctrl+c to finish recording. 
  • run the commands between the ### blocks below:
    ####################
    for f in *tiff ; do convert -quality 100 $f `basename $f tiff`jpg; done
    mencoder "mf://*rgb.jpg" -mf fps=10 -o rgb.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800
    mencoder "mf://*depth.jpg" -mf fps=10 -o depth.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800
    mkdir images_rgb
    mv *_rgb.* images_rgb
    mkdir images_depth
    mv *_depth.* images_depth
    ####################
If all went well, a big pile of files (rgb.avi, depth.avi, *.jpg, *.tiff) await you. Enjoy!

No comments:

Post a Comment