Skip to content

Commit d2dadc8

Browse files
author
Brandyn A. White
committed
Updated readme
Signed-off-by: Brandyn A. White <[email protected]>
1 parent d4bbfb1 commit d2dadc8

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

wrappers/python/README

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
11
Brandyn White
22
33

4+
This is the Cython-based libfreenect Python wrappers. This provides async (e.g., using callbacks) and sync (e.g., simple function calls) interfaces to libfreenect. The majority of the runloop is abstracted so that later upstream modifications will have minimal impact on your code; however, you are free to implement your own runloop and access all available functionality.
5+
6+
7+
Why Cython
8+
I wrote several iterations of these wrappers in Pure C, Ctypes, and Cython. Cython is by far the easiest to maintain (as the main lib changes regularly) while maintaining C-like speed. It does require Cython to install the C code; however, this is available for all supported platforms. If this becomes a burden we can easily include the generated C code in the repo. The other dependencies are the same for pure C python extensions.
9+
10+
Install
11+
- Get cython, python-dev, python-numpy
12+
- Optional, get opencv (2.1+ with python wrappers), Matplotlib
13+
- Global Install: sudo python setup.py install
14+
- Local Directory Install: python setup.py build_ext --inplace
15+
16+
Do you need to run everything with root?
17+
No. Use the udev drivers available in the project main directory.
18+
19+
Differences From C Library
20+
Things that are intentially different to be more Pythonic
21+
- init/open_device: Different calling style (returns the new value as opposed to using a double pointer)
22+
- Names: Everything is in the freenect module. Since all freenect functions are of the form freenect_blah, we use freenect.blah to refer to them. This is also true for the synchronous calls.
23+
24+
Things not implemented (though could be added)
25+
- get/set user: Not implemented
26+
- Dev/Ctx/State: Opaque classes wrapping void *'s (you can't access struct elements)
27+
- Log functionality and callback
28+
29+
Additional Features
30+
- get_accel: A helper function that simplifies the accelerometer handling
31+
- runloop: An abstraction that takes in depth, rgb, and body callbacks. The body is called in the 'freenect_process_events' loop. Depth and RGB callbacks are given numpy arrays of the returned data.
32+
- Integration with the c_sync wrapper: Provides sync_get_depth (get the depth without needed a callback) and sync_get_rgb (same for rgb
33+
- Kill exception to stop the runloop from within the body)
34+
435

536
Build with (goes in this directory)
637
python setup.py build_ext --inplace
738

839
To use fakenect, use this to point at it's directory
9-
sudo LD_PRELOAD="/usr/local/lib/fakenect/libfreenect.so" FAKENECT_PATH="thanksgiving0" python demo_cv_depth_show.py
10-
11-
This provides a synchronous api in cython. It handles the kinect callback events in a background thread.
12-
See demo_cv_depth_sync_show.py for an example.
40+
LD_PRELOAD="/usr/local/lib/fakenect/libfreenect.so" FAKENECT_PATH="../../build/utils/legos0/" ./demo_cv_sync.py
1341

14-
sudo LD_LIBRARY_PATH="/usr/local/lib" python demo_cv_depth_sync_show.py
42+
The synchronous calls are performed using the c_sync wrapper (no threading is done in Python).
43+
Run this for an example
44+
./demo_cv_sync.py

wrappers/python/freenect.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ cdef extern from "libfreenect.h":
5858
int freenect_num_devices(void *ctx)
5959
int freenect_open_device(void *ctx, void **dev, int index)
6060
int freenect_close_device(void *dev)
61-
#void freenect_set_user(void *dev, void *user)
62-
#void *freenect_get_user(void *dev)
6361
void freenect_set_depth_callback(void *dev, freenect_depth_cb cb)
6462
void freenect_set_rgb_callback(void *dev, freenect_rgb_cb cb)
6563
int freenect_set_rgb_format(void *dev, int fmt)

0 commit comments

Comments
 (0)