1

Closed

PyKinect Get Color Pixel Coordinates From Depth Pixel Help

description

Hi,

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\convert_data.py", line 47, in <module>
    xyz_list.append(depth_to_xyz(rgb_list[0],depth_list[0],skeleton,camera))
  File "C:\Users\Michael\Google Drive\Dissertation\room\convert_data.py", 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\__init__.py", 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\_interop.py", 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 _interop.py 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

comments

mikeybam wrote Mar 26, 2013 at 4:20 PM

I edited _interop.py to be ctypes.byref however all I get when I try to run the function as I did above is
Image
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 _interop.py line 175 just needs to become:

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