Python bindings to libfreenect2.
- Python2 (python3 support : https://github.com/LovelyHorse/py3freenect2)
- Numpy
- Scipy (as appropriated by python version) :
- Python Imaging Library (used for scipy.misc.im* functions) : http://www.pythonware.com/products/pil/
- OpenCV
To install, run sudo python setup.py install
.
For usage, see test.py
.
General approach:
- Grab frames in a loop calling
frames = frameListener.waitForNewFrame()
. - Read individual frames like
rgbFrame = frames.getFrame(pyfreenect2.Frame.COLOR)
. - Obtain raw data e.g.
color_frame = rgbFrame.getBGRData()
. - Do something with it - for example render it using OpenCV.
- Important Release the frames via
frameListener.release()
at the end of the loop.
- Test everything
You can probably find more TODOs in Issues or by grep -R TODO .
.
- Registration
- Pipeline argument
- The original code didn't compile on my machine when calling
import_array()
. I fixed the makro in the C++ code.
- We've only tested this running on system (brew's Cellar) Python, not in any virtual environment.
- Make sure libfreenect2 is installed properly. They've got a section on how to install on Mac OS X.
- Once completed, make sure OpenCV and its Python bindings are installed. Instruction can be found online or brew can be used.
- Run
recorder.py
in the examples folder of this repository. Make sure the configuration items within that file (folders) are set to valid and existing locations on disk. - Use the commandline argument
--s
to specify a sub-folder to dump the data in. - Use the c-Key to start capturing. Use the c-Key again to stop capturing. You should see RGB-D pairs being saved in the location specified in the configuration items.
- Sometimes the program crashes due to LIB_USB exceptions, I unfortunately don't have a workaround for that other than restarting the process.
- Before quitting make sure to leave the program open for a couple of seconds due to output buffers being emptied by the storage thread.