PyKinect Get Color Pixel Coordinates From Depth Pixel Help

Mar 26, 2013 at 12:46 PM
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!!!
Coordinator
Mar 26, 2013 at 4: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.
Coordinator
Mar 26, 2013 at 4: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 4:21 PM
Edited Mar 26, 2013 at 4:21 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! Is it something wrong in the way I call it?
Coordinator
Mar 26, 2013 at 8: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 26, 2013 at 11:41 PM
Cheers that would be great! I'm really stuck with my project until I can get this sorted out...
Mar 28, 2013 at 4:39 PM
Hi Dinov? I wonder if you managed to get anywhere with this? Many thanks
Apr 2, 2013 at 11:34 PM
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...
Coordinator
Apr 4, 2013 at 9: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.