Has anybody made Python bindings?

130 views
Skip to first unread message

MattY

unread,
Jan 5, 2011, 1:32:04 AM1/5/11
to OpenNI
Has anybody written some Python bindings?

Makes prototyping so much easier and opens the framework up to a whole
new class of people - as we saw in the libfreenect project.

If no, is anybody interested in doing this?

somedude

unread,
Jan 5, 2011, 11:50:13 AM1/5/11
to OpenNI
python is the only reason ive been trying to use libfreenect.
(unsuccessfully, cant get it to compile correctly)

gamix

unread,
Jan 5, 2011, 1:47:19 PM1/5/11
to OpenNI
I am already hard at work on some high quality bindings for Python. My
purpose is to integrate the Kinect with an ongoing research project in
computer vision that I have been working on over the past year or so.
The existing code base for this project is rather sizable and written
almost entirely in Python with bindings to other libraries such as
OpenCV. For me developing this binding was almost a no-brainer and I
willing to share it with the community if other people find it
useful.

I need to work on it at least for another week before I can consider
releasing it though.

wayfarer_boy

unread,
Jan 6, 2011, 5:15:35 AM1/6/11
to OpenNI
That's excellent news, gamix. I for one would love to start using a
Python wrapper with OpenNI. I'm looking to convert gestures to /dev/
Mouse||Keyboard||Joystick using Gizmo (http://sourceforge.net/apps/
mediawiki/gizmod/index.php?title=How_Gizmod_Works), as well as mapping
live skeletal capture to 3D models in the Blender Game Engine, and
I've only just started trying to code in C++ to try an achieve this
(with no success and a great deal of frustration).

MattY

unread,
Jan 6, 2011, 6:37:10 AM1/6/11
to OpenNI
Hi gamix

Very glad to hear it - your work will certainly be widely
appreciated.
Sounds like you've got it under control but if you need help (release
testing?) please ask.

May I ask about your method? (ctypes, cython, boost.....?)

Cheers
Matt

salexkidd

unread,
Jan 9, 2011, 3:05:50 PM1/9/11
to OpenNI
Hi. My name is salexkidd.

The OpenNI, Mono / .NET is available...This means that... Yes! Iron
Python !

(I use a Mac. Using Mono Framework ;) )

$ ipy2

>>> import clr
>>> import System
>>> from System import Threading
>>> clr.AddReferenceToFile("OpenNI.net.dll")
>>> clr.AddReferenceToFile("XnVNite.net.dll")
>>> import xn
>>> import xnv
>>> print (xn)
['AlternativeViewPointCapability',......]

>>> print (xnv)
['Axis', 'Broadcaster', 'Circle', 'Direction', 'FlowRouter',......]


>>> context = xn.Context("Sample-Tracking.xml")
>>> session_mgr = xnv.SessionManager(context, "Wave", "RaiseHand")
>>> flow_router = xnv.FlowRouter()
>>> selectable_slider = xnv.SelectableSlider1D(3, xnv.Axis.X)
.
.
.

thx

On 1月5日, 午後3:32, MattY <mattyye...@gmail.com> wrote:
> Has anybody written somePythonbindings?
>

Ziv Hendel

unread,
Jan 9, 2011, 3:51:39 PM1/9/11
to OpenNI
Very nice!
Please feel free to contribute a Python wrapper to OpenNI...
I think people will appreciate this :-)

Thanks,
Ziv.

wayfarer_boy

unread,
Jan 11, 2011, 5:28:43 AM1/11/11
to OpenNI
How are the bindings coming along, gamix? Anything to test yet?

On Jan 5, 6:47 pm, gamix <gnatan...@gmail.com> wrote:
> I am already hard at work on some high quality bindings forPython. My
> purpose is to integrate the Kinect with an ongoing research project in
> computer vision that I have been working on over the past year or so.
> The existing code base for this project is rather sizable and written
> almost entirely inPythonwith bindings to other libraries such as

MattY

unread,
Jan 17, 2011, 7:10:21 PM1/17/11
to OpenNI, gamix
Hi Gamix,

How are your Python bindings going for OpenNI/NITE?


Would love to see these, even in a preliminary state!

Cheers,
MattY

gamix

unread,
Jan 18, 2011, 1:44:18 PM1/18/11
to OpenNI
Hello Everyone,
Thank you, I really appreciate your support! The bindings are coming
out fine. I managed to expose the basic functionality of OpenNI,
namely the image and depth streams to Python. Now that the core of the
wrapper is down, it should be much easier to expose more
functionality.

A few years ago, I would have used SWIG to do something like this, but
in my experience automatically generated bindings tend to be somewhat
unreliable, and my immediate need is just to tap into a smaller subset
of OpenNI's functionality. So, I used Boost Python instead to get me
more fine grained control.

I am planning to put out an initial preliminary release of the code
within the next couple of days on Google Code. I would like to make
the code most useful to everyone for both commercial and non-
commercial use. Any advice on which standard open source licence I
should go for and still be compatible with the core of OpenNI/NITE?

While the binding is still at a preliminary stage, the code is
relatively clean, and the basic structure should be straightforward
enough for other people to contribute, so I am quite excited to share
my work with you!

I tried to make the API pretty faithful to OpenNI/NITE. Here is sample
on how to use it for your consideration:

def unitTestImageGenerator():

global g_context

g_context = ONIPY.OpenNIContext()
g_context.InitFromXmlFile( OPENNI_INITIALIZATION_FILE )

imageGenerator = ONIPY.OpenNIImageGenerator()

returnCode = g_context.FindExistingNode( \
ONIPY.XN_NODE_TYPE_IMAGE, \
imageGenerator )

returnCode = g_context.WaitAndUpdateAll()

if returnCode == ONIPY.XN_STATUS_OK:
print "update was successful"
else:
print "update was not successful"

if imageGenerator.IsValid():

# NOTE: the meta data is exposed directly through the generator
print "X resolution: ", imageGenerator.XRes()
print "Y resolution: ", imageGenerator.YRes()

g_context.Shutdown()

-gamix

On Jan 17, 4:10 pm, MattY <mattyye...@gmail.com> wrote:
> Hi Gamix,
>
> How are yourPythonbindings going for OpenNI/NITE?

gamix

unread,
Jan 20, 2011, 1:59:57 PM1/20/11
to OpenNI
I released a preliminary version of the binding on Google Code. I
created a new forum post with more details to follow up this
discussion here:

http://groups.google.com/group/openni-dev/browse_thread/thread/736c2a51e49bfb37

-Gamix

On Jan 18, 10:44 am, gamix <gnatan...@gmail.com> wrote:
> Hello Everyone,
> Thank you, I really appreciate your support! The bindings are coming
> out fine. I managed to expose the basic functionality of OpenNI,
> namely the image and depth streams toPython. Now that the core of the
> wrapper is down, it should be much easier to expose more
> functionality.
>
> A few years ago, I would have used SWIG to do something like this, but
> in my experience automatically generated bindings tend to be somewhat
> unreliable, and my immediate need is just to tap into a smaller subset
> of OpenNI's functionality. So, I used BoostPythoninstead to get me
> more fine grained control.
>
> I am planning to put out an initial preliminaryreleaseof the code

wayfarer_boy

unread,
Jan 21, 2011, 4:29:40 AM1/21/11
to OpenNI
Brilliant news, Gamix. Congratulations. Testing and will feedback :)

On Jan 20, 6:59 pm, gamix <gnatan...@gmail.com> wrote:
> I released a preliminary version of the binding on Google Code. I
> created a new forum post with more details to follow up this
> discussion here:
>
> http://groups.google.com/group/openni-dev/browse_thread/thread/736c2a...
Reply all
Reply to author
Forward
0 new messages