Kinect: How do i ID the first tracked skeleton and do stuff with it after(Kinect:我如何识别第一个跟踪的骨架并在之后用它做些什么)
问题描述
我如何识别 kinect 跟踪的第一个骨架,然后对其进行处理.我只对第一个骨架感兴趣,以后我不需要它们.最好根本不跟踪进入的下一个骨架.
How can i ID the first skeleton the kinect tracked and then do stuff with it. Im only interested in the first skeleton and whichever comes after i do not need them. Preferably the next skeleton that comes in is not tracked at all.
谁能帮我这个谢谢.目前我使用的下面的代码不起作用.我尝试了一些快速的 linq 查询,但我不太确定如何使用它.总是有错误.
Can someone help me with this thanks. Currently the code below im using does not work. I have tried some quick linq query but im not very sure how to use it. Always having errors with it.
谁能给我一些我可以使用的例子提前谢谢!
Can someone give me some examples i can work with thanks in advance!!
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);
}
}
using (DrawingContext dc = this.drawingGroup.Open())
{
// Draw a transparent background to set the render size
dc.DrawRectangle(Brushes.Black, null, new Rect(160, 0.0, RenderWidth, RenderHeight));
if (skeletons.Length != 0)
{
foreach (Skeleton skel in skeletons)
{
RenderClippedEdges(skel, dc);
if (skel.TrackingState == SkeletonTrackingState.Tracked)
{
this.TrackingId = Skel;
sensor.SkeletonStream.AppChoosesSkeletons = true;
sensor.SkeletonStream.ChooseSkeletons(skel.TrackingId);
this.DrawBonesAndJoints(skel, dc);
if (skel == null)
{
Process.Start("wmplayer.exe", "C:\Users\User\Downloads\Test.wma");
}
}
else if (skel.TrackingState == SkeletonTrackingState.NotTracked)
{
sensor.SkeletonStream.AppChoosesSkeletons = false;
}
}
}
// prevent drawing outside of our render area
this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(160, 0.0, RenderWidth, RenderHeight));
}
}
推荐答案
这段代码只能追踪一个骨架:
You can track only one skeleton with this piece of code:
int trackingID;
skeletonTracked = new Skeleton();
bool first = true;
Skeleton skeleton;
Skeleton[] skeletons = new Skeleton[6];
...
public void AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
using (SkeletonFrame sFrame = e.OpenSkeletonFrame())
{
sFrame.CopySkeletonDataTo(skeletons);
skeleton = (from s in skeletons where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault();
if (skeleton == null)
return;
}
using (DrawingContext dc = this.drawingGroup.Open())
{
// Draw a transparent background to set the render size
dc.DrawRectangle(Brushes.Black, null, new Rect(160, 0.0, RenderWidth, RenderHeight));
RenderClippedEdges(skel, dc);
if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
{
if (first)
{
skeletonTracked = skeleton;
trackingId = skeleton.TrackingID;
...
first = false;
}
if (skeleton.TrackingID == trackingId)
{
...
}
}
...
}
}
此代码查找检测到的第一个骨架,如果它的跟踪 ID 等于检测到的第一个骨架,则对它执行操作,否则您不对稍后检测到的其他骨架执行操作.但是,我会看到 Kinect 用户检测,因为它具有其他单独检测骨架的方法ID/索引.ID 的方法非常适合区分多个玩家,但对于每个骷髅来说,它们的变化很大.索引会保存很短的时间,因此您可以编写一些代码来检测骨架是否离开了框架.
This code finds the first skeleton detected, if it's tracking ID is equal to the first one detected, then you perform operations with it, otherwise you don't perform operations on other skeletons that are detected later. However, I would see Kinect user Detection as it has other methods of detecting skeletons with seperate ids/indexes. The method of IDs is great for distinguishing between multiple players, but they change largely for every skeleton. The indexes are saved for a short time so you could have some code for detecting that the skeleton left the frame.
这篇关于Kinect:我如何识别第一个跟踪的骨架并在之后用它做些什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Kinect:我如何识别第一个跟踪的骨架并在之后用它
基础教程推荐
- SSE 浮点算术是否可重现? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01