Skip to content

Commit

Permalink
Moved ctypes version to it's own directory, cython is now the preferr…
Browse files Browse the repository at this point in the history
…ed version

Signed-off-by: Brandyn A. White <[email protected]>
  • Loading branch information
Brandyn A. White authored and qdot committed Nov 27, 2010
1 parent ee2cd33 commit bc42d54
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 81 deletions.
56 changes: 9 additions & 47 deletions wrappers/python/README
Original file line number Diff line number Diff line change
@@ -1,52 +1,14 @@
** Freenect Ctypes Wrapper **
- Brandyn White ([email protected])
- Andrew Miller ([email protected])
Brandyn White
[email protected]

- Description
This wrapper can be used to write Python code to control the Kinect using the
Freenect library. This is simpler than a module as it does not need to be
compiled. The entire freenect library is exposed at the module level including
enumerated constants and function pointer wrappers. Note that due to the C
driver not having udev support, the python script must be run with root.

- Requirements
Python 2.5+
Build with (goes in this directory)
python setup.py build_ext --inplace

- Optional Libraries
numpy: sudo apt-get install python-numpy - Note: Not required but this is the recommended interface
matplotlib: sudo apt-get install python-matplotlib
opencv 2.1: sudo apt-get install libcv-dev libcv2.1 libcvaux2.1 python-opencv libhighgui2.1
To use fakenect, use this to point at it's directory
sudo LD_LIBRARY_PATH="../../../fakenect/" FAKENECT_PATH="thanksgiving0" python demo_cv_depth_show.py

- Installation
Compile freenect by following the directions in README.asciidoc at the project
root. This module should "just work" because it checks it's current directory
and the build directory for the dynamic library (also checking for platform
specific extensions).
This provides a synchronous api in cython. It handles the kinect callback events in a background thread.
See demo_cv_depth_sync_show.py for an example.

If you want to use this script outside of it's directory copy the shared library
(e.g., .so, .dynlib, .dll) along with this module. At the time of this writing,
this is accomplished by

libfreenect/python$ cp ../c/build/lib/libfreenect.* .

- Examples
demo_mp_depth_show: Use matplotlib's imshow command to display the depth image. Requires: matplotlib and numpy
demo_mp_rgb_show: Use matplotlib's imshow command to display the RGB image. Requires: matplotlib and numpy
demo_tilt: Uses a thread to grab sensor data while tilting and changing the LED. This works with just python.
demo_cv_depth_show: Use opencv's ShowImage to display depth. Requires: Numpy and opencv (new python bindings)
demo_cv_rgb_show: Use opencv's ShowImage to display RGB. Requires: Numpy and opencv (new python bindings)

- How to run a demo
sudo python demo_tilt.py
sudo python demo_cv_depth_show.py
sudo python demo_mp_depth_show.py

- Callbacks
There are 3 callback interfaced you can choose from.
depth_cb_string_factory + rgb_cb_string_factory
depth_cb_array_factory + rgb_cb_array_factory
depth_cb_np_factory + rgb_cb_np_factory

They all have specific documentation in their docstring. The general structure
is that you make a function, pass it into a factory, and run the "runloop" with
"rgb" and/or "depth" set the output of the factory you chose.
sudo LD_LIBRARY_PATH="/usr/local/lib" python demo_cv_depth_sync_show.py
14 changes: 0 additions & 14 deletions wrappers/python/cython/README

This file was deleted.

17 changes: 0 additions & 17 deletions wrappers/python/cython/demo_cv_depth_show.py

This file was deleted.

4 changes: 1 addition & 3 deletions wrappers/python/demo_cv_depth_show.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env python
import freenect
import cv
import numpy as np

cv.NamedWindow('Depth')


def display(dev, data, timestamp):
data -= np.min(data.ravel())
data *= 65536 / np.max(data.ravel())
Expand All @@ -16,4 +14,4 @@ def display(dev, data, timestamp):
data.dtype.itemsize * data.shape[1])
cv.ShowImage('Depth', image)
cv.WaitKey(5)
freenect.runloop(depth=lambda *x: display(*freenect.depth_cb_np(*x)))
freenect.runloop(lambda *x: display(*freenect.depth_cb_np(*x)))
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions wrappers/python_ctypes/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
** Freenect Ctypes Wrapper **
- Brandyn White ([email protected])
- Andrew Miller ([email protected])

- Description
This wrapper can be used to write Python code to control the Kinect using the
Freenect library. This is simpler than a module as it does not need to be
compiled. The entire freenect library is exposed at the module level including
enumerated constants and function pointer wrappers. Note that due to the C
driver not having udev support, the python script must be run with root.

- Requirements
Python 2.5+

- Optional Libraries
numpy: sudo apt-get install python-numpy - Note: Not required but this is the recommended interface
matplotlib: sudo apt-get install python-matplotlib
opencv 2.1: sudo apt-get install libcv-dev libcv2.1 libcvaux2.1 python-opencv libhighgui2.1

- Installation
Compile freenect by following the directions in README.asciidoc at the project
root. This module should "just work" because it checks it's current directory
and the build directory for the dynamic library (also checking for platform
specific extensions).

If you want to use this script outside of it's directory copy the shared library
(e.g., .so, .dynlib, .dll) along with this module. At the time of this writing,
this is accomplished by

libfreenect/python$ cp ../c/build/lib/libfreenect.* .

- Examples
demo_mp_depth_show: Use matplotlib's imshow command to display the depth image. Requires: matplotlib and numpy
demo_mp_rgb_show: Use matplotlib's imshow command to display the RGB image. Requires: matplotlib and numpy
demo_tilt: Uses a thread to grab sensor data while tilting and changing the LED. This works with just python.
demo_cv_depth_show: Use opencv's ShowImage to display depth. Requires: Numpy and opencv (new python bindings)
demo_cv_rgb_show: Use opencv's ShowImage to display RGB. Requires: Numpy and opencv (new python bindings)

- How to run a demo
sudo python demo_tilt.py
sudo python demo_cv_depth_show.py
sudo python demo_mp_depth_show.py

- Callbacks
There are 3 callback interfaced you can choose from.
depth_cb_string_factory + rgb_cb_string_factory
depth_cb_array_factory + rgb_cb_array_factory
depth_cb_np_factory + rgb_cb_np_factory

They all have specific documentation in their docstring. The general structure
is that you make a function, pass it into a factory, and run the "runloop" with
"rgb" and/or "depth" set the output of the factory you chose.
File renamed without changes.

0 comments on commit bc42d54

Please sign in to comment.