本文介绍了如何使用kinect跟踪两个骷髅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在做一个大学项目(游戏乒乓球)。我可以识别一个骨架并做出手势来控制一个painel。我搜索过,我试图识别两个骷髅来控制另一个painel,但是我不能这样做。  这就是我到目前为止: private void SensorSkeletonFrameReady(object sender,SkeletonFrameReadyEventArgs e) { Skeleton [] skeletons = new Skeleton [0]; 使用(SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if(skeletonFrame!= null) { skeletons = new Skeleton [skeletonFrame .SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(skeletons); } if(skeletons.Length!= 0) { foreach(骷髅骨架中的骨架) { if(skel.TrackingState == SkeletonTrackingState.Tracked) { this.tracked(skel); } } } } } public void tracked(Skeleton skeleton) { Joint jHandRight = skeleton.Joints [JointType.HandRight]; 联合jHipCenter = skeleton.Joints [JointType.HipCenter]; if((jHipCenter.Position.Z - jHandRight.Position.Z)> 0.2) { //考虑在他们面前举手 //System.Diagnostics .Debug.WriteLine(" Hand:Raised"); //MessageBox.Show("POR FAVORRRRRRRR"); // moving [0] = false; movement [0] = true; 运动[1] =假; } 其他 { //用户侧降低了手牌 //System.Diagnostics.Debug.WriteLine("Hand:Lowered"); //MessageBox.Show("A SERRRRIIIIIOOOOOOOOOOOOOO"); //移动[1] =假; 运动[1] =真; movement [0] = false; } } 任何人都可以帮助我。 解决方案 你的代码中存在逻辑问题 foreach(骷髅骨架中的骨架) { if(skel.TrackingState) == SkeletonTrackingState.Tracked) { this.tracked(skel); } } 您必须定义一种方法来区分一个骨架,并为每个骨架执行特定操作。 例如,您可以使用全局骨架位置来定义骨架必须控制的面板。 foreach(骷髅骨架) { if(skel.TrackingState == SkeletonTrackingState.Tracked) { if(skel.Position.X< 0) //左侧的用户 this.controlLeftPanel(skel); else //右侧用户 this.controlRightPanel(skel); } } I'm doing a project (game pong) to college. I can recognize one skeleton and make gestures to control one painel. I searched and I tried to recognize two skeletons to control the another painel, but I can't do it. This is what I have so far:private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { Skeleton[] skeletons = new Skeleton[0]; using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(skeletons); } if (skeletons.Length != 0) { foreach (Skeleton skel in skeletons) { if (skel.TrackingState == SkeletonTrackingState.Tracked) { this.tracked(skel); } } } } } public void tracked(Skeleton skeleton) { Joint jHandRight = skeleton.Joints[JointType.HandRight]; Joint jHipCenter = skeleton.Joints[JointType.HipCenter]; if ((jHipCenter.Position.Z - jHandRight.Position.Z) > 0.2) { //Consider hand raised in front of them //System.Diagnostics.Debug.WriteLine("Hand: Raised"); //MessageBox.Show("POR FAVORRRRRRRR"); //movement[0] = false; movement[0] = true; movement[1] = false; } else { //Hand is lowered by the users side //System.Diagnostics.Debug.WriteLine("Hand: Lowered"); //MessageBox.Show("A SERRRRIIIIIOOOOOOOOOOOOOO"); //movement[1] = false; movement[1] = true; movement[0] = false; } }Anyone could help me, please. 解决方案 There is a logic problem in your codeforeach (Skeleton skel in skeletons){ if (skel.TrackingState == SkeletonTrackingState.Tracked) { this.tracked(skel); }}You must define a way to distinguish one skeleton to another and do a specific action for each.For example, you can use the global skeleton position to define which panel has to be control by the skeleton.foreach (Skeleton skel in skeletons){ if (skel.TrackingState == SkeletonTrackingState.Tracked) { if (skel.Position.X < 0) // user on the left side this.controlLeftPanel(skel); else // user on the right side this.controlRightPanel(skel); }} 这篇关于如何使用kinect跟踪两个骷髅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-24 12:44