|
1 | 1 | Brandyn White
|
2 | 2 |
|
3 | 3 |
|
| 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 | + |
4 | 35 |
|
5 | 36 | Build with (goes in this directory)
|
6 | 37 | python setup.py build_ext --inplace
|
7 | 38 |
|
8 | 39 | 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 |
13 | 41 |
|
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 |
0 commit comments