Notice: MediaWiki has been updated. Report any rough edges to marcan@marcan.st

Python Wrapper

From OpenKinect
Revision as of 17:22, 27 November 2010 by Gourneau (talk | contribs)
Jump to: navigation, search

"Python API, Documents and Stuff"

About

There are two Python interface implementations: Ctypes and Cython. They are compatible and any incompatibilities can be considered bugs. The reason for having both is that the Ctypes will work without any other dependencies, where Cython has additional build requirements; however, Cython will be more efficient and is a convenient language for pre-processing the sensor data. The interface is designed to mimic the C library except where 1.) It is impractical or 2.) It would be "Un-Pythonic" to do so. See "Differences with C Library" for specific instances of this. The exposed interface support both asynchronous (e.g., callback) and synchronous (e.g., call and block) functions which is enabled by the C_Sync_Wrapper.

A variety of demos are provided using all available kinect features with examples for Matplotlib and OpenCV display.

Who is involved

Search for Python in People

However (Brandyn) and (amiller) are trying to organize things for Python.

Differences with C Library

Functions in the C library of the form freenect_blah are accessed as freenect.blah. The reason for this is Python has good module level namespace support and the function name's differ by 1 character. This also goes for enumerated constants that have the FREENECT_ prefix.

The init functions all return the initialized value as opposed to using the C-style of passing a double pointer.

In C:

 freenect_init(&ctx, 0)

Becomes:

 ctx = init()

How to compile

TODO

Example Python Scripts

(amiller) has a few Python demo scripts at https://github.com/amiller/pykinect

TODO