如何在Microsoft Kinect SDK v 1.0中锁定单个骨架? [英] How to lock in a single skeleton in Microsoft Kinect SDK v 1.0?

查看:121
本文介绍了如何在Microsoft Kinect SDK v 1.0中锁定单个骨架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,其中我必须只有一个用户并锁定它,这样即使有人走近,即使该人离Kinect更近,该应用程序也会继续跟踪它所跟踪的第一个骨架. >
从msdn库中,我发现我可以使用Skeleton Stream类:

属性:AppChoosesSkeletons =获取或设置一个布尔值,该值确定应用程序是否选择要跟踪的骨架.

方法:SkeletonStream.ChooseSkeletons(Int32)=选择一个要跟踪的骨架.语法:public void ChooseSkeletons(int trackingId1)

我不太擅长编程,我正在使用C#,我曾想过将类似的代码写下来,但是它表示我正在使用无效表达式.

有人可以帮我吗?谢谢!

I''m creating an application in which I must have only one user and lock it so if somebody else comes along, even if that person is closer to Kinect, the application keeps tracking the first skeleton it tracked.

From the msdn library I found I could use the Skeleton Stream Class:

Property: AppChoosesSkeletons = Gets or sets a Boolean value that determines whether the application chooses which skeletons to track.

Method: SkeletonStream.ChooseSkeletons (Int32) = Chooses one skeleton to track. Syntax: public void ChooseSkeletons (int trackingId1)

I''m not very good with programming and I''m using C#, I thought of writing something like the code down, but it says that I''m using an Invalid Expression.

Could someone please help me? Thx!

SkeletonFrame SFrame = e.OpenSkeletonFrame(); 
if (SFrame == null) return; 
 
Skeleton[] Skeletons = new Skeleton[SFrame.SkeletonArrayLength]; 
SFrame.CopySkeletonDataTo(Skeletons); 
 
int firstSkeleton = Skeletons[0].TrackingId; 
sensor.SkeletonStream.ChooseSkeletons(int firstSkeleton); 
 
if (firstSkeleton == null) 
return; 
 
if (SkeletonTrackingState.Tracked == firstSkeleton.TrackingState) 
{ 
//body... 

推荐答案

以下是您的代码中的一些小建议:

Here are a few minor suggestions in your code:

SkeletonFrame SFrame = e.OpenSkeletonFrame(); 
if (SFrame == null) return; 
 
Skeleton[] skeletons = new Skeleton[SFrame.SkeletonArrayLength]; 
SFrame.CopySkeletonDataTo(skeletons); 
 
int firstSkeleton = Skeletons[0].TrackingId;
 
sensor.SkeletonStream.ChooseSkeletons(firstSkeleton); 
 

 
if (SkeletonTrackingState.Tracked == firstSkeleton.TrackingState)




将骨架重命名为骨架可以避免与同名的Kinect命名空间对象发生潜在的命名冲突.
int类型的数据永远不能为null.空检查也是在您已经习惯了变量之后.删除了冗余代码.

调用方法时,您传递变量时,您无需先指定类型,然后再指定变量.




Making Skeletons renamed as skeletons avoids potential naming conflict with a Kinect namespace object of the same name.
Data of type int can never be null. Your null check was also AFTER you already used to variable. Removed the redundant code.

When calling a method you pass your variable you do not specify a type then the variable.


这篇关于如何在Microsoft Kinect SDK v 1.0中锁定单个骨架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆