This project has moved. For the latest updates, please go here.


PyKinect Get Color Pixel Coordinates From Depth Pixel Help



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!!!
Closed Oct 3, 2013 at 12:17 AM by RickWinter


mikeybam wrote Mar 26, 2013 at 4:20 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!

dinov wrote Jun 4, 2013 at 6:39 PM

Sorry for the really long delay - the issue here is that we weren't passing self in, so in line 175 just needs to become:

_NuiInstance._NuiImageGetColorPixelCoordinatesFromDepthPixel(self, eColorResolution, pcViewArea, lDepthX, lDepthY, usDepthValue, ctypes.byref(x), ctypes.byref(y))