cannot get pykinect to work

Apr 18, 2012 at 6:13 PM

I'm trying to use pykinect for a school project. I just installed cpython 2.7 (via enthought), pvts, pygame, kinect sdk, pykinect on my win7 machine. When i run the KinectGame sample code I get a blank cmd prompt window and a blank game window. The skeletons are not being displayed. 

Also, when I try to run the more involved sample here: https://hg01.codeplex.com/pytools/raw-file/76d5a3d3bf67/Release/Product/Python/PyKinect/PyKinect/PyGameDemo.py, I get a blank window again with the error "Unhandled exception in thread started by <bound method Runtime._event_thread of <pykinect.nui.Runtime object at 0x02A8BED0>>"

I'm not even sure where to begin bebugging. If anyone could shed some light on what might be going wrong i would greatly appreciated.

 

Coordinator
Apr 18, 2012 at 6:37 PM

Can you try this simple code:

 

from pykinect import nui
with nui.Runtime() as kinect:
    kinect.skeleton_engine.enabled = True
    while True:
        frame = kinect.skeleton_engine.get_next_frame()
        for skeleton in frame.SkeletonData:
            print skeleton

And see if that prints anything out?  This will just dump all of the skeleton data received from the Kinect.

If that prints stuff out next you can try:

from pykinect import nui
with nui.Runtime() as kinect:
    kinect.skeleton_engine.enabled = True
    while True:
        frame = kinect.skeleton_engine.get_next_frame()
        for skeleton in frame.SkeletonData:
            if skeleton.eTrackingState == nui.SkeletonTrackingState.TRACKED:
                print skeleton

Which will only print out skeletons if they're tracked. 

If the 1st one works and the 2nd one doesn't then it's not picking up any skeletons and you might just need to adjust the camera positioning.

You might want to try downloading the KinectDemos http://pytools.codeplex.com/releases/view/85004#DownloadId=366379  zip file - that has a more recent version of PyGameDemo (along w/ the code I pasted above).  There may have been some changes which require some updates.

Apr 19, 2012 at 8:54 PM

appreciate your help dinov, the skeleton is working now.

May 17, 2012 at 9:30 AM

Good morning all,

I am trying to run pykinect on python 2.5. I do not know if it is possible. I know it is not supported, but the only reason why the code was not working were some ctypes.c_bool in nui/__init__, and those types were not there in Python 2.5. To solve that, c_bool=ctypes.c_int and replacing ctypes.c_bool with c_bool in that file worked.

Also, some @ symbols in interop created problem. I commented them, I do not know if that could be the reason for the issue I am having now.

I am able to import pykinect in python 2.5.4. I call  nui.runtime(). but if I tried the code suggested by dinov (need to

add from __future__ import with_statement

on top to use the with statement in Python 2.5) I get:

With the first example:

Traceback (most recent call last):  File "C:\Users\ab11akb\Desktop\pykin.py", line 8, in <module>    print skeleton  File "C:\Python25\lib\site-packages\pykinect\nui\structs.py", line 262, in __repr__    return '<Tracking: {0}, ID: {1}, Position: {2}>'.format(self.eTrackingState, self.dwTrackingID, self.Position)AttributeError: 'str' object has no attribute 'format'

And with the second:

Traceback (most recent call last):  File "C:\Users\ab11akb\Desktop\pykin.py", line 6, in <module>    frame = kinect.skeleton_engine.get_next_frame()  File "c:\Python25\Lib\site-packages\pykinect\nui\__init__.py", line 291, in get_next_frame    res = self.runtime._nui.NuiSkeletonGetNextFrame(timeout)  File "c:\Python25\Lib\site-packages\pykinect\nui\_interop.py", line 200, in NuiSkeletonGetNextFrame    _NuiInstance._NuiSkeletonGetNextFrame(self, dwMillisecondsToWait, ctypes.byref(frame))  File "\loewis\25\python\Modules\_ctypes\callproc.c", line 757, in GetResult  File "c:\Python25\Lib\site-packages\pykinect\nui\_interop.py", line 33, in _check_retval_    raise errpykinect.nui.KinectError: [Error -2097086458] Feature not initialized

I googled but I couldn't find any similar issue, can I ask if someone knows what's the problem and how to solve this?

Many thanks,

Angelo

May 17, 2012 at 3:07 PM

PyKinect requires cPython 2.7

http://channel9.msdn.com/coding4fun/kinect/PyKinect-Yep-Python-and-Kinect-in-Visual-Studio-yet

May 17, 2012 at 6:35 PM

Thanks, I solved my issue: I have now pykinect running in Python 2.5.4 - using the idle. I might release the egg, msg me or if you think it is the case I could release the egg.

The problem was that the format function is also introduced in Python 2.7, used % instead.

Many thanks,

Angelo

May 17, 2012 at 7:45 PM

I'd love to have a pyKinect for 2.6, as that is the version of Python we're on here at work. str().format() was backported from Python 3.x all the way down to 2.6x

Coordinator
May 17, 2012 at 8:34 PM

Can you open an issue?  There's some updates that need to be done for Kinect in general and I can take a look at making sure it runs on 2.6 at the same time.

May 17, 2012 at 9:44 PM

I just created an issue with the same topic, and uploaded my modified version there. Hope I did it right with the issue, sorry but was my first one!

I haven't done that much with that yet, I can keep you updated if there should be other issues. 

Thanks

Mar 9, 2015 at 5:47 PM
Sorry, I am just a beginner both for Python and Kinect environment.
I have installed Python 2.7 with pyGame 1.9 for Visual Studio 2013 with PTVS. I just wanted to know if CPython is different from the Python installation? Basically I have the same problem as stated in this query above! TIA