none
Initialization Fails - HRESULT: 0x80070016 RRS feed

  • Question

  • I have another issue regarding initializing the kinect, this is my code at the moment:

                if (KinectSensor.KinectSensors.Count > 0)
                {
                    kinect = KinectSensor.KinectSensors[0];
                    if (kinect.Status == KinectStatus.Connected)
                    {
                        kinect.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
                        kinect.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
                        kinect.SkeletonStream.Enable();
                        kinect.Start();
                    }
                }
     

    It is exactly what was done in the 'Setting up your Development Environment' quick start video, my program ran a few times before, but now using the exact same code it always fails at 'kinect.Start();' with the following error:

    System.InvalidOperationException was unhandled
      Message=This API has returned an exception from an HRESULT: 0x80070016
      Source=Microsoft.Kinect
      StackTrace:
           at Microsoft.Kinect.KinectExceptionHelper.CheckHr(Int32 hr)
           at Microsoft.Kinect.KinectSensor.Initialize(SensorOptions options)
           at Microsoft.Kinect.KinectSensor.Start()
           at Kinect3D.Game.OnLoad(EventArgs e) in C:\Users\DS\Documents\Visual Studio 2010\Kinect3D\Kinect3D\Program.cs:line 122
           at OpenTK.GameWindow.OnLoadInternal(EventArgs e)
           at OpenTK.GameWindow.Run(Double updates_per_second, Double frames_per_second)
           at OpenTK.GameWindow.Run(Double updateRate)
           at Kinect3D.Game.Main() in C:\Users\DS\Documents\Visual Studio 2010\Kinect3D\Kinect3D\Program.cs:line 770
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.Runtime.InteropServices.COMException
           Message=The device does not recognize the command. (Exception from HRESULT: 0x80070016)
           ErrorCode=-2147024874
           InnerException: 
    
    The Kinect Explorer sample runs and compiles fine. I don't know what is wrong, the exact same code may run yesterday but wont run today!

    Friday, February 17, 2012 1:06 AM

Answers

  • Although this might be minor, best practice provided from the Kinect Explorer is to enumerate the devices instead of using the index.

    foreach (KinectSensor sensor in KinectSensor.KinectSensors)
    {
        if (sensor.Status == KinectStatus.Connected)
        {
            sensor.ColorStream.Enable();
            sensor.DepthStream.Enable();
            sensor.DepthStream.Range = DepthRange.Near;
            sensor.AllFramesReady += new EventHandler(KinectSensor_AllFramesReady);
            sensor.Start();
    
            this.kinect = sensor;
    
            break;
        }
    }

    Additionally, are you using the Kinect for Windows hardware or the Xbox360 version?



    Friday, February 17, 2012 1:28 AM

All replies

  • Although this might be minor, best practice provided from the Kinect Explorer is to enumerate the devices instead of using the index.

    foreach (KinectSensor sensor in KinectSensor.KinectSensors)
    {
        if (sensor.Status == KinectStatus.Connected)
        {
            sensor.ColorStream.Enable();
            sensor.DepthStream.Enable();
            sensor.DepthStream.Range = DepthRange.Near;
            sensor.AllFramesReady += new EventHandler(KinectSensor_AllFramesReady);
            sensor.Start();
    
            this.kinect = sensor;
    
            break;
        }
    }

    Additionally, are you using the Kinect for Windows hardware or the Xbox360 version?



    Friday, February 17, 2012 1:28 AM
  • Thank you for your reply, I just tried the code you suggested and now at 'sensor.Start()' I get this error:

    System.InvalidOperationException was unhandled
      Message=The feature is not supported by this version of the hardware
      Source=Microsoft.Kinect
      StackTrace:
           at Microsoft.Kinect.KinectExceptionHelper.CheckHr(Int32 hr)
           at Microsoft.Kinect.NuiSensor.NuiImageStreamOpen(_NUI_IMAGE_TYPE eImageType, _NUI_IMAGE_RESOLUTION eResolution, UInt32 dwImageFrameFlags, UInt32 dwFrameLimit, IntPtr hNextFrameEvent, IntPtr& phStreamHandle)
           at Microsoft.Kinect.ImageStream.Open()
           at Microsoft.Kinect.ImageStream.Start()
           at Microsoft.Kinect.KinectSensor.Initialize(SensorOptions options)
           at Microsoft.Kinect.KinectSensor.Start()
           at Kinect3D.Game.OnLoad(EventArgs e) in C:\Users\DS\Documents\Visual Studio 2010\Kinect3D\Kinect3D\Program.cs:line 134
           at OpenTK.GameWindow.OnLoadInternal(EventArgs e)
           at OpenTK.GameWindow.Run(Double updates_per_second, Double frames_per_second)
           at OpenTK.GameWindow.Run(Double updateRate)
           at Kinect3D.Game.Main() in C:\Users\DS\Documents\Visual Studio 2010\Kinect3D\Kinect3D\Program.cs:line 787
      InnerException: 

    I am using the Xbox360 version of Kinect, could this be the problem? I wasn't aware that they were different.

    Edit: I found out the reason why the "Feature not supported by this version of the Hardware" error came up, its because of the DepthRange.Near line. It seems to be working now! Thanks!
    • Edited by daisun Friday, February 17, 2012 4:00 AM
    Friday, February 17, 2012 2:51 AM
  • correct, XBox Kinect does not support Near Mode.
    Friday, February 17, 2012 5:14 AM