KinectSensor NullReferenceException

半世苍凉 提交于 2019-12-11 11:39:19

问题


A week ago, we had a working project. The following worked, without a problem on my machine (Window 8 developing in VisualStudio 2010)

KinectSensor sensor = KinectSensor.KinectSensors[0];
public KinectController()
    {
        sensor.SkeletonFrameReady += runtime_SkeletonFrameReady;
        sensor.ColorStream.Enable();
        sensor.SkeletonStream.Enable();
        sensor.Start();
    } 

This worked no problems. When my teammate pulled this down from an SVN, it broke, giving a null reference exception on ColorStream.Enable(). Deleting and adding the Microsoft.Kinect reference, for some reason, fixed it in the past, but now, it seems as though it is broken permanently. I ALWAYS throws an exception at this line. In debug, the ColorStream and SkeletonStream are null, even though it was clearly instantiated. Even doing

KinectSensor sensor;
public KinectController()
    {
        sensor = KinectSensor.KinectSensors[0];
        sensor.SkeletonFrameReady += runtime_SkeletonFrameReady;
        sensor.ColorStream.Enable();
        sensor.SkeletonStream.Enable();
        sensor.Start();
    } 

will throw the null reference exception. What is happening? Why is this throwing an exception? It broke just as we were ready to present it, which is disheartening to even program with Kinect again.

来源:https://stackoverflow.com/questions/17118753/kinectsensor-nullreferenceexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!