none
Kinect - INuiFrameTexture from ImageFrame structure RRS feed

  • Question

  • Hi, I am currently in the process of wrapping the microsoft SDK to be available for use with Unity3D. I have got the skeletal streams working and I am now slowed down trying to get the Colour streams to work.

    Here are my declared external methods, which point to the various Image related functions, taken from the header files located in the SDKs folder.

    [DllImport(@"C:\Windows\System32\Kinect10.dll", EntryPoint = "NuiImageStreamOpen")]
             public static extern int OpenImageStream(ImageTypeFlags imageType,ImageResolution imageRes,ImageStreamFlags streamFlags,
                 uint frameLimit,IntPtr nextFrameEvent,ref IntPtr openedStream);
    
             [DllImport(@"C:\Windows\System32\Kinect10.dll", EntryPoint = "NuiImageStreamGetNextFrame")]
             public static extern int GetNextImageFrame(IntPtr imageStream, uint millisecondsToWait,ref IntPtr imageFrame);
    
             [DllImport(@"C:\Windows\System32\Kinect10.dll", EntryPoint = "NuiImageStreamReleaseFrame")]
             public static extern int ReleaseImageStream(IntPtr openedStream, IntPtr frame);


    I receive no errors opening the stream, by using the following:

    result = Kinect.OpenImageStream(ImageTypeFlags.colour, ImageResolution.res640x480, 0, 2, IntPtr.Zero, ref colorStreamHandle);

    result returns 0.

    colorStreamHandle is also an IntPtr.

    The GetNextImageFrame also returns no error. Now, near to my question :), the following link http://msdn.microsoft.com/en-us/library/nuiimagecamera.nuiimagestreamgetnextframe says that the last parameter of GetNextImageFrame is "A pointer that receives a pointer to a NUI_IMAGE_FRAME structure that contains the next image frame in the specified stream. The pFrameTexture member of the structure points to an INuiFrameTexture instance that contains the frame data."

    Ok, my problem:

    I managed to extract the Image frame structure from the handle using :

    ImageFrame imageFrame = (ImageFrame)Marshal.PtrToStructure(imageStreamPtr,typeof(ImageFrame));

    But, I'm pretty sure the main thing I need is the values from pFrameTexture. The MSDN says the INuiFrameTexture  is similar to a Direct3D texture, but has only one level ...what does this mean? What does the pFrameTexture actually contain? I am currently attempting to write the INuiFrameTexture interface inside my C# code like this:

    [ComImport]
        [Guid("13ea17f5-ff2e-4670-9ee5-1297a6e880d1"),
        InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 
        interface INuiFrameTexture
        {
        }

    Should I be doing this?

    Basically, I need to know how to access the data from the pFrameTexture object. Is there a structure layout I can use which will store the values the pFrameTexture has? Sorry for long post.



    Monday, July 30, 2012 3:04 PM