安装 primesense

来源:互联网 发布:仿苹果6splus淘宝店 编辑:程序博客网 时间:2024/06/07 05:37

源于:https://answers.ros.org/question/132146/what-is-the-best-way-to-record-rgb-and-depth-data-from-a-kinect-using-openni/

https://pypi.python.org/pypi/primesense/2.2.0.30-3

Ok, so the solution I found is a little specific to my project. I determined that OpenNI .oni files will work as video file output for my purposes. If anyone is reading this and wants to go all the way to .avi files, if you try my solution and then add this:

http://kirilllykov[dot]github[dot]io/blog/2013/03/19/convert-openni-star-dot-oni-files-into-avi/

(replace '[dot]' with '.') solution on top of that, you should be able to get to .avi files.

To get the .oni files from the RGB and depth data, I first downloaded OpenNI (okay, so I already had OpenNI from before, but the ROS version isn't the same as the release version, so I downloaded that and put it in it's own folder) from here:

http://www[dot]openni[dot]org/openni-sdk/

(replace '[dot]' with '.') (Note, I'm running Linux, so this may work slightly differently for you if you are running something else). I extracted the folder and just placed it in my home directory (so it didn't interfere with ROS's OpenNI). Next I downloaded Primesense:

https://pypi[dot]python[dot]org/pypi/primesense/2.2.0.30-3

(replace '[dot]' with '.') which adds python bindings for OpenNI. I ran

setup.py build

and

setup.py install

from the Primesense folder to install the necessary libraries. I then ran the following python code to record the .oni files:

import roslibimport rospyfrom primesense import openni2openni2.initialize(OPENNI_REDIST_DIR)    dev = openni2.Device.open_any()depth_stream = dev.create_depth_stream()color_stream = dev.create_color_stream()depth_stream.start()color_stream.start()rec = openni2.Recorder("test.oni")rec.attach(depth_stream)rec.attach(color_stream)print rec.start()#Do stuff hererec.stop()depth_stream.stop()color_stream.stop()openni2.unload()

where OPENNI_REDIST_DIR is the path to the redist folder in the OpenNI library. You can play these back just to double-check that they worked by running 'NiViewer' (in the Tools folder of the OpenNI library) with the path to the .oni file.


原创粉丝点击