Depth-image wont show RRS feed

  • Question

  • Hi

    I followed the simple example shown in

    The rgb-image shows but not the depth-image, and I don't get any errors. 
    I don't think that the debugger steps into the "nui_DepthFrameReady"-function.
    I've tried to run the Skeletal Viewer example code from VS10 and that depth-image works.

    What is most likely the problem?



    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Microsoft.Research.Kinect.Nui;
    using Coding4Fun.Kinect.Wpf;
    namespace WpfApplication1
      /// <summary>
      /// Interaction logic for MainWindow.xaml
      /// </summary>
      public partial class MainWindow : Window
        public MainWindow()
        Runtime nui = new Runtime();
        private void Window_Loaded(object sender, RoutedEventArgs e)
          nui.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseDepth);
          nui.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nui_VideoFrameReady);
          nui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480,
          nui.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nui_DepthFrameReady);
          nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.Depth);
        void nui_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
          image2.Source = e.ImageFrame.ToBitmapSource();
        void nui_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
          image1.Source = e.ImageFrame.ToBitmapSource();     
        private void Window_Closed(object sender, EventArgs e)


    Tuesday, June 21, 2011 9:52 AM


  • Hi,

    "Camera Fundamentals" still works. I installed the latest Kinect SDK but I still get the same error.
    You don't have to keep digging into this if you don't want to Eddy. It's probably something silly, and
    since the example works I can use that. 

    Monday, August 8, 2011 6:42 AM

All replies

  • Tobias,

    Have you verified that all code in Window_Loaded gets executed without throwing an exception? Do you see any exception reports in debug output?

    Also, are you saying that if you put a breakpoint in the line that reads:

    image2.Source = e.ImageFrame.ToBitmapSource();

    it never gets executed?


    I'm here to help
    Wednesday, June 22, 2011 6:31 AM
  • Yepp, when I put a breakpoint at that line it never gets executed. I don't get any exceptions, I think ;)


    Friday, July 1, 2011 2:19 PM
  • Hmmm, I'm not entirely sure. Do things work better if you switch the order in which you open stream and register for event? E.g.:

    nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.Depth);
    nui.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nui_DepthFrameReady);


    I'm here to help
    Saturday, July 2, 2011 12:26 AM
  • I'm having a similar problem. I tried both stream/event orderings and I don't get any skeleton images. Could it have something to do with framerate? As in, a depth frame has higher priority than a skeleton frame and the depth frame gets sent first, so by the time the skeleton frame would be ready, another depth frame is too and goes first?

    Wednesday, July 13, 2011 10:09 PM
  • Hello!

    Try that:

    kinectSensor.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
    kinectSensor.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
    kinectSensor.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
    kinectSensor.VideoFrameReady +=
    new EventHandler<ImageFrameReadyEventArgs>(kinectSensor_VideoFrameReady);
    kinectSensor.DepthFrameReady +=
    new EventHandler<ImageFrameReadyEventArgs>(kinectSensor_DepthFrameReady);


    Monday, July 18, 2011 9:12 PM
  • @CsGyuri:

    I tried your suggestion. Now I get a stream of the color image and one still image of the depht.


    Monday, July 25, 2011 8:39 AM
  • @Eddy

    If I put the open streams first, nui_VideoFrameReady(...) gets executed one time, then it only gets into nui_DepthFrameReady(...); 

    If I put the lines with " += new EventHandler" first, it never enters nui_VideoFrameReady(...) at all, only nui_DepthFrameReady(...);

    But why does the color image show and get updated when it only enters  nui_DepthFrameReady(...) ??
    Monday, July 25, 2011 9:07 AM
  • Tobias,

    Try changing your nui_DepthFrameReady to be:

    void nui_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
      PlanarImage Image = e.ImageFrame.Image;
      image2.Source = BitmapSource.Create(
            Image.Width, Image.Height, 96, 96, PixelFormats.Bgr565, null, Image.Bits, Image.Width * Image.BytesPerPixel);

    and see if that works better.

    I'm here to help
    Tuesday, July 26, 2011 8:09 AM
  • Nothing changed, still a blank image.
    Tuesday, July 26, 2011 10:35 AM
  • Tobias,

    At this point I don't know how to help you more unless you were willing to share your entire project code with me so I can see the whole picture of what you're doing. If you'd rather not do that, then I'd recommend starting from the Skeletal Viewer example code which does work for you.

    How exactly did you use for help? Did you just type code in as you saw it from video, or did you get the channel9  quickstarts from and start from there?


    I'm here to help
    Tuesday, July 26, 2011 7:40 PM
  • Hi

    Thanks for the link to the quick start samples, the "CameraFundamentals"-project is exactly what I have been trying to replicate by typing it in myself.
    That code works perfectly so I tried to swap out everything in my files with the code those files. Then I noticed the exception I was getting in my version:

    "A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Research.Kinect.dll"

    Does that mean anything to you?

    Thanks for all your help

    Wednesday, July 27, 2011 7:17 AM
  • Well, many different operations may throw InvalidOperationException depending on the state of your system. If it's thrown by Runtime.Initialize, it may be that your kinect is not plugged in to USB or to external power, if it's thrown by ImageStream.Open, it could mean that you're trying to use an image resolution that is not supported.

    Can you follow steps outlined in to edit your app.xaml to have attribute


    and then add this code to your App class in app.xaml.cs:

    private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)

    Then you will see the full exception callstack in the debug output and if you paste it back here I'll be able to help you more.

    I'm here to help
    Wednesday, July 27, 2011 6:07 PM
  • Now I get this message:


     Message=Failed in native DLL. HRESULT=0x80040224.
        at Microsoft.Research.Kinect.Nui.Runtime.Initialize(RuntimeOptions options)
        at WpfApplication1.MainWindow.Window_Loaded(Object sender, RoutedEventArgs e) in C:\Users\tobpah\Dropbox\WpfApplication1\WpfApplication1\MainWindow.xaml.cs:line 38
        at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
        at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
        at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
        at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
        at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
        at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
        at MS.Internal.LoadedOrUnloadedOperation.DoWork()
        at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
        at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
        at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
        at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
        at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
        at System.Windows.Interop.HwndTarget.OnResize()
        at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
        at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
        at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
        at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
        at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
        at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

    Thursday, August 4, 2011 11:23 AM
  • Hmm, if you launch the "Camera Fundamentals" project again, does it still work?

    1) If Camera Fundamentals no longer works either, then maybe you've changed the HW configuration of your system, such as adding more USB devices that conflict with Kinect Device, accidentally turned off the power supply to kinect device, or something of that sort.

    2) If "Camera Fundamentals" project works unmodified but your modified project doesn't work, then my best guess is that your application is trying to call Runtime.Initialize multiple times without calling Runtime.Uninitialize in between. Also, Beta 1 for SDK had a couple of problems with multiple-initialization of same instance of Runtime object which were fixed with Beta 1 Refresh of SDK, so if that sounds like it could be related, I recommend you install SDK refresh from

    Let me know if that helps,

    I'm here to help
    Friday, August 5, 2011 11:01 PM
  • Hi,

    "Camera Fundamentals" still works. I installed the latest Kinect SDK but I still get the same error.
    You don't have to keep digging into this if you don't want to Eddy. It's probably something silly, and
    since the example works I can use that. 

    Monday, August 8, 2011 6:42 AM