两帧之间的关节速度 [英] velocity of a joint between two frames

查看:88
本文介绍了两帧之间的关节速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好, 


我在这个问题上一直在堆叠,我真的很感激,如果有人可以帮助我。 


我在许多论坛上多次问过,我搜索了很多,但没有回答真正帮助我。


我正在开发一个应用程序,我必须使用vs c#2012计算骨骼体关节的速度和kinect sdk 1.7


在问这个问题之前我首先要确定事物的逻辑,


如果我理解正确,delta_time我正在寻找计算速度,不是一帧的持续时间(1 / 30s),但必须从两个时刻计算: 

1-检测并保存"关节点"的瞬间。在第一帧中,在检测并保存相同的"关节点"的瞬间,在下一帧中


如果不是这样,感谢您澄清事情。


从这个假设开始,我写了一个代码:


- 检测一个人


- 跟踪脊柱关节==>如果它被跟踪,那么将其坐标保存到列表中(我简化了Y轴上的工作以简化)


- 选择保存坐标的时间 


- 增加framecounter(最初等于零)


- 如果帧计数器是> 1 计算速度(x2 - x1)/(T2 - T1)并保存它


这里是一段代码:

 


  System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
       双msNow;
       双msPast;
       双差异;
        TimeSpan currentTime;
        TimeSpan lastTime = new TimeSpan(0);

  &NBSP;列表与LT;双> Sylist = new List< double>();

private int framecounter = 0;

private void KinectSensorOnAllFramesReady(object sender,AllFramesReadyEventArgs allFramesReadyEventArgs)
{
Skeleton first = GetFirstSkeleton(allFramesReadyEventArgs);


if(first == null)//如果没有骨架
{
txtP.Text ="没有人检测到'; //(空闲模式)
return;
}

其他
{
txtP.Text =""检测到某人";
skeletonDetected = true;

///看看这个人是否被完全检测到



find_coordinates(first);

/ *******************************
*时间计算*
/ ******************************* /

currentTime = stopWatch.Elapsed;
msNow = currentTime.Seconds * 1000 + currentTime.Milliseconds;
if(lastTime.Ticks!= 0)
{
msPast = lastTime.Seconds * 1000 + lastTime.Milliseconds;
diff = msNow - msPast;
}
lastTime = currentTime;



}


// framecounter ++;
}
void find_coordinates(Skeleton first)
{

// *修改07052014 ***** /

联合脊柱= first.Joints [JointType.Spine];
if(Spine.TrackingState == JointTrackingState.Tracked)
{

double Sy = Spine.Position.Y;
/ *******************************
*时间开始*
/ * ****************************** /
stopWatch.Start();

Sylist.Add(Sy);
framecounter ++;

}

其他
返回;

if(framecounter> 1)
{

double delta_Distance = Sylist [Sylist.Count] - Sylist [Sylist.Count - 1];


}


}




<在这种情况下,我真的不知道如何使用时间跨度和秒表(我的意思是当有帧可以处理多次/秒时) 


我将感激不尽任何帮助!










DKF

解决方案

情侣。


1。回顾一下如何获得跟踪骨架。你如何确定你正在使用的骨架是你想要的骨架?

如何在C#中访问跟踪的骨架数据

http://msdn.microsoft.com/en-us/library/jj131025.aspx


2 。你为什么要用计时器?甚至骨架框架也包含时间戳。这将确保您准确计算帧之间的时差。


http://msdn.microsoft.com/en-us/library/microsoft.kinect.skeletonframe.timestamp.aspx


Hello, 

I'm stack for along time in this problem and i will really appreciate if any one could help me in that. 

I  asked many times in many forums, i've searched alot but no answer that really helped me.

i'm developping an application where i have to calculate the velocity of a joint of skeleton body using vs c# 2012 and kinect sdk 1.7

i have first to be sure of  the logic of things before asking this question so,

if I understood correctly, the delta_time i'm looking for to calculate velocity, is not the duration of one frame (1/30s) but it must be calculated from two instants: 
1- the instant when detecting and saving the "joint point" in the first frame 
2- the instant when detecting and saving the same "joint point" in the next frame

if it's not true, thank you for clarifying things.

starting from this hypothesis, i wrote a code to :

- detectiong a person

- tracking the spine joint ==> if it's is tracked then saving its coordinates into a list (I reduced the work for the moment on the Y axis to simplify)

- pick up the time when saving the coordinates 

- increment the framecounter (initially equal to zero)

- if the frame counter is > 1  calculate velocity ( x2 - x1)/(T2 - T1) and save it

here is a piece of the code:


 System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
        double msNow;
        double msPast;
        double diff;
        TimeSpan currentTime;
        TimeSpan lastTime = new TimeSpan(0);

   List<double> Sylist = new List<double>();

private int framecounter = 0;

private void KinectSensorOnAllFramesReady(object sender, AllFramesReadyEventArgs allFramesReadyEventArgs) { Skeleton first = GetFirstSkeleton(allFramesReadyEventArgs); if (first == null) // if there is no skeleton { txtP.Text = "No person detected"; // (Idle mode) return; } else { txtP.Text = "A person is detected"; skeletonDetected = true; /// look if the person is totally detected find_coordinates(first); /******************************* * time computing * /*******************************/ currentTime = stopWatch.Elapsed; msNow = currentTime.Seconds * 1000 + currentTime.Milliseconds; if (lastTime.Ticks != 0) { msPast = lastTime.Seconds * 1000 + lastTime.Milliseconds; diff = msNow - msPast; } lastTime = currentTime; } //framecounter++; } void find_coordinates(Skeleton first) { //*modification 07052014 *****/ Joint Spine = first.Joints[JointType.Spine]; if (Spine.TrackingState == JointTrackingState.Tracked) { double Sy = Spine.Position.Y; /******************************* * time starting * /*******************************/ stopWatch.Start(); Sylist.Add(Sy); framecounter++; } else return; if (framecounter > 1) { double delta_Distance = Sylist[Sylist.Count] - Sylist[Sylist.Count - 1]; } }

to be honnest, i dont really know how ti use timespan and stopwatch in this context ( i mean when there are frames to process many times/s) 

i will be thankfull for any help !



DKF

解决方案

Couples of things.

1. review how you get a tracked skeleton. How are you determining the skeleton you are using is the one you want?
How to access tracked skeleton data in C#
http://msdn.microsoft.com/en-us/library/jj131025.aspx

2. why are you using a timer? Even skeleton frame contains a timestamp. This will ensure you are accurately calculating the time difference between frames.

http://msdn.microsoft.com/en-us/library/microsoft.kinect.skeletonframe.timestamp.aspx


这篇关于两帧之间的关节速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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