本文介绍了Kinect手指跟踪代码出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最初我得到了这个例外,



然后我在第311行解决了这个问题,使用if和else:


  double firstLine = cursorTop + 3 +(outputPos * 7);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int fingerIdx = 0; fingerIdx< 5; fingerIdx ++)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;试试
  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;   数组f = Enum.GetValues(typeof(Hand.FingerJointType));

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;数组fNames = Enum.GetNames(typeof(Hand.FingerJointType));

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int idxInEnum = fingerIdx * 3;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Microsoft.Kinect.DepthSpacePoint [] p = new Microsoft.Kinect.DepthSpacePoint [3];

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string [] jointNames = new string [3];

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int j = 0; j
  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Hand.FingerJointType jt =(Hand.FingerJointType)f.GetValue(idxInEnum + j);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;&NBSP; &NBSP;
  if(hand.FingerJoints.ContainsKey(jt))

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; p [j] = hand.FingerJoints [jt];

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show(" Not Found");

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;&NBSP; &NBSP;   jointNames [j] =(string)fNames.GetValue(idxInEnum + j);


现在我的屏幕在第一个Kinect帧暂停到达并显示messageBox未找到。我的代码需要此密钥,任何人都可以告诉我如何在我的代码中添加此密钥..




软件工程专业学生。

解决方案

Initially i got this Exception,

Then i fix this problem at line 311, using if and else:

 double firstLine = cursorTop + 3 + (outputPos * 7);
            for (int fingerIdx = 0; fingerIdx < 5; fingerIdx++)
            {
                try
                {
                    Array f = Enum.GetValues(typeof(Hand.FingerJointType));
                    Array fNames = Enum.GetNames(typeof(Hand.FingerJointType));
                    int idxInEnum = fingerIdx * 3;
                    Microsoft.Kinect.DepthSpacePoint[] p = new Microsoft.Kinect.DepthSpacePoint[3];
                    string[] jointNames = new string[3];
                    for (int j = 0; j < 3; j++)
                    {
                        Hand.FingerJointType jt = (Hand.FingerJointType)f.GetValue(idxInEnum + j);
                       if (hand.FingerJoints.ContainsKey(jt))
                        {
                            p[j] = hand.FingerJoints[jt];
                        }
                        else
                        {
                            MessageBox.Show("Not Found");
                        }
                        jointNames[j] = (string)fNames.GetValue(idxInEnum + j);

Now my screen is pausing at first Kinect Frame arrival and Displaying the messageBox Not Found. My code requires this Key, Can anyone tell me how to add this key in my code..


Student of Software Engineering.

解决方案


这篇关于Kinect手指跟踪代码出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:55