This project has moved and is read-only. For the latest updates, please go here.

PyKinect Get Color Pixel Coordinates From Depth Pixel Help

Mar 26, 2013 at 1:46 PM

What I am trying to do is to get 3d coordinates from my Kinect and a matching colour from the video stream. I have successfully converted depth values to 3d coordinates however I cannot get the method for converting depth to a position in the colour array to work. I make a call such as:
pixel = camera.get_color_pixel_coordinates_from_depth_pixel(nui.ImageResolution.Resolution320x240, nui.ImageViewArea, xpos, ypos, depth[ypos][xpos])
However I get the following error:
Traceback (most recent call last):
  File "C:\Users\Michael\Google Drive\Dissertation\room\", line 47, in <module>
  File "C:\Users\Michael\Google Drive\Dissertation\room\", line 27, in depth_to_xyz
    pixel = camera.get_color_pixel_coordinates_from_depth_pixel(nui.ImageResolution.Resolution320x240, nui.ImageViewArea, xpos, ypos, depth[ypos][xpos] << 3)
  File "C:\Python27\lib\site-packages\pykinect\nui\", line 382, in get_color_pixel_coordinates_from_depth_pixel
    return self.runtime._nui.NuiImageGetColorPixelCoordinatesFromDepthPixel(color_resolution, view_area, depth_x, depth_y, depth_value)
  File "C:\Python27\lib\site-packages\pykinect\nui\", line 175, in NuiImageGetColorPixelCoordinatesFromDepthPixel
    _NuiInstance._NuiImageGetColorPixelCoordinatesFromDepthPixel(eColorResolution, pcViewArea, lDepthX, lDepthY, usDepthValue, byref(x), byref(y))
NameError: global name 'byref' is not defined
I think that byref should be ctypes.byref in however when I edit the file to do this I get a Runtime Error message popup.

Please help, I'm going absolutely spare on this one!!!
Mar 26, 2013 at 5:05 PM
This looks like a bug in PyKinect, if you change the two "byref(x)" and "byref(y)" calls to be "ctypes.byref(x)" and "ctypes.byref(y)" it should work. Thanks for the report, I'll change this into a bug.
Mar 26, 2013 at 5:05 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Mar 26, 2013 at 5:21 PM
Edited Mar 26, 2013 at 5:21 PM
I edited to be ctypes.byref however all I get when I try to run the function as I did above is
So I have no idea what is wrong now! Is it something wrong in the way I call it?
Mar 26, 2013 at 9:49 PM
Probably not, I suspect it's a bug in the wrapper API. I don't have everything setup to look at it right now, but I'll try and look at it tomorrow and get back to you.
Mar 27, 2013 at 12:41 AM
Cheers that would be great! I'm really stuck with my project until I can get this sorted out...
Mar 28, 2013 at 5:39 PM
Hi Dinov? I wonder if you managed to get anywhere with this? Many thanks
Apr 3, 2013 at 12:34 AM
I tried downgrading my SDK to V1.0 however I still have a similar problem. After calling get_color_pixel_coordinates_from_depth_pixel I don't get the same runtime error all I get is Idle not responding and have to restart the shell.

Is there an example program I can try to see if my implementation is wrong... I inserted a debug statement into get_color_pixel_coordinates_from_depth_pixel which prints correctly so the issue is in the call to _NuiInstance._NuiImageGetColorPixelCoordinatesFromDepthPixel.

I hope this helps...
Apr 4, 2013 at 10:59 PM
Hi mikeybam - just wanted to stay that we haven't forgotten about your issue. Just very very busy trying to get a release out; we'll be back to normal by ~ end of next week.