2016-04-12 16 views
0

için ortak ad atama Her bir eklemeye bir ad atayım. çağıran fonksiyonudur:Kinect: Joint

for(int t=0;t<body._body.Length;t++) 
     { 
      DrawPoint(body._body[t], canvs,col_t,col_i); 
     } 

ve tam çekme noktasının fonksiyonu: Ancak

public static void DrawPoint(JointData _joint, Canvas canvs, Color col_t, Color col_i) 
    { 

     #region convert JointData to Kinect.Joint type 
     Joint currentJoint; 
     currentJoint.TrackingState = JointTrackingState.NotTracked; 
     currentJoint.Position.X = -1; 
     currentJoint.Position.Y = -1; 
     currentJoint.Position.Z = -1; 
     currentJoint.JointType = JointType.AnkleLeft; 

     if (_joint._TrackState == "Tracked") 
      currentJoint.TrackingState = JointTrackingState.Tracked; 
     if (_joint._TrackState == "Inferred") 
      currentJoint.TrackingState = JointTrackingState.Inferred; 
     if (_joint._TrackState == "NotTracked") 
      currentJoint.TrackingState = JointTrackingState.NotTracked; 

     if (_joint._jointType == "AnkleLeft") 
      currentJoint.JointType = JointType.AnkleLeft; 
     if (_joint._jointType == "AnkleRight") 
      currentJoint.JointType = JointType.AnkleRight; 
     if (_joint._jointType == "ElbowLeft") 
      currentJoint.JointType = JointType.ElbowLeft; 
     if (_joint._jointType == "ElbowRight") 
      currentJoint.JointType = JointType.ElbowRight; 
     if (_joint._jointType == "FootLeft") 
      currentJoint.JointType = JointType.FootLeft; 
     if (_joint._jointType == "FootRight") 
      currentJoint.JointType = JointType.FootRight; 
     if (_joint._jointType == "HandLeft") 
      currentJoint.JointType = JointType.HandLeft; 
     if (_joint._jointType == "HandRight") 
      currentJoint.JointType = JointType.HandRight; 
     if (_joint._jointType == "HandTipLeft") 
      currentJoint.JointType = JointType.HandTipLeft; 
     if (_joint._jointType == "HandTipRight") 
      currentJoint.JointType = JointType.HandTipRight; 
     if (_joint._jointType == "Head") 
      currentJoint.JointType = JointType.Head; 
     if (_joint._jointType == "HipLeft") 
      currentJoint.JointType = JointType.HipLeft; 
     if (_joint._jointType == "HipRight") 
      currentJoint.JointType = JointType.HipRight; 
     if (_joint._jointType == "KneeLeft") 
      currentJoint.JointType = JointType.KneeLeft; 
     if (_joint._jointType == "KneeRight") 
      currentJoint.JointType = JointType.KneeRight; 
     if (_joint._jointType == "Neck") 
      currentJoint.JointType = JointType.Neck; 
     if (_joint._jointType == "ShoulderLeft") 
      currentJoint.JointType = JointType.ShoulderLeft; 
     if (_joint._jointType == "ShoulderRight") 
      currentJoint.JointType = JointType.ShoulderRight; 
     if (_joint._jointType == "SpineBase") 
      currentJoint.JointType = JointType.SpineBase; 
     if (_joint._jointType == "SpineMid") 
      currentJoint.JointType = JointType.SpineMid; 
     if (_joint._jointType == "SpineShoulder") 
      currentJoint.JointType = JointType.SpineShoulder; 
     if (_joint._jointType == "ThumbLeft") 
      currentJoint.JointType = JointType.ThumbLeft; 
     if (_joint._jointType == "ThumbRight") 
      currentJoint.JointType = JointType.ThumbRight; 
     if (_joint._jointType == "WristLeft") 
      currentJoint.JointType = JointType.WristLeft; 
     if (_joint._jointType == "WristRight") 
      currentJoint.JointType = JointType.WristRight; 

     currentJoint.Position.X = (float)Convert.ToDouble(_joint._position[0]); 
     currentJoint.Position.Y = (float)Convert.ToDouble(_joint._position[1]); 
     currentJoint.Position.Z = (float)Convert.ToDouble(_joint._position[2]); 
     #endregion 

     #region drawing 

     Color currentColor = Colors.Blue; 

     if (currentJoint.TrackingState == TrackingState.NotTracked) return; 

     //if (currentJoint.TrackingState == TrackingState.Inferred) currentColor = Colors.Yellow; 
     if (currentJoint.TrackingState == TrackingState.Inferred) currentColor = col_i; 
     //if (currentJoint.TrackingState == TrackingState.Tracked) currentColor = Colors.Green; 
     if (currentJoint.TrackingState == TrackingState.Tracked) currentColor = col_t; 

     currentJoint = ScaleTo(currentJoint, canvs.ActualWidth, canvs.ActualHeight); 

     Ellipse ellipse = new Ellipse 
     { 
      Width = 8, 
      Height = 8, 
      Fill = new SolidColorBrush(currentColor) 
     }; 

     Canvas.SetLeft(ellipse, currentJoint.Position.X - ellipse.Width/2); 
     Canvas.SetTop(ellipse, currentJoint.Position.Y - ellipse.Height/2); 

     canvs.Children.Add(ellipse); 
     #endregion 

    } 

, ben çizgi

currentJoint.TrackingState = JointTrackingState.NotTracked; 

atanmamış yerel değişken Kullanımı "işte hatayı olsun currentJoint '" ve daha sonra currentJoint.Position ve currentJoint.JointType hatalarını döndür" Bu hata,' Joint.Position 'değerinin dönüş değeri değiştirilemiyor çünkü değişken "ve" Özellik veya dizinleyici 'Joint.JointType' atanamaz - sırasıyla "salt okunur".

Bu hataları nasıl düzeltebilirim? Şimdiden teşekkür ederim!

cevap

0

Henüz bir problem buldunuz mu? Bunun yanlış olabileceğini görebileceğim tek şey, Joint currentJoint;'un Joint currentJoint = new Joint(); olarak değiştirilmesi gerektiğidir. Bu, sorunu çözer.

İlgili konular