English 中文(简体)
NullReferenceException on OpenSkeleton 框架
原标题:NullReferenceException on OpenSkeletonFrame
  • 时间:2012-05-14 15:38:35
  •  标签:
  • c#
  • kinect

Hello, I have a NullReferenceException in implementing this:

void newSensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
    {
        Skeleton first = GetFirstSkeleton(e);
        if (first == null)
        {
            return;
        }
        /**
         * @TODO
         * obsluzyc wyjatek null reference na wypadek gdy gubi szkielet
         */ 
        long timestamp = e.OpenSkeletonFrame().Timestamp;

它符合<代码>长期封顶。

如果采取同样行动,则有10-15秒钟。 例如,I m砍伐的一些数据仍然存在。 我在每一个框架中都记录这些内容。 在几秒之后,我收到了<代码>NullReferenceException。

问题是什么?

最佳回答

Ok so I fouund answer for my problem. It is very simple.

我的系统/机器负荷过重,或者从任何其他理由框架中慢慢慢慢慢慢慢慢慢慢慢慢慢慢慢慢慢。 当这一滞后发生时,我可以开一个框架。 因此,我没有这样做。

问题的解决办法

bool haveSkeletonData = false;
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame != null)
{
    if ((this.skeletonData == null) || (this.skeletonData.Length != skeletonFrame.SkeletonArrayLength))
    {
        this.skeletonData = new Skeleton[skeletonFrame.SkeletonArrayLength];
    }
    skeletonFrame.CopySkeletonDataTo(skeletonData);
    haveSkeletonData = true;
}
else
{
    haveSkeletonData = false;
}
}

if (haveSkeletonData)
{
   // here i can put code that is using my timestamp 
}

这样一来,我就能够安全,我就能够使用我的时光,因为我需要:

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签