C# 读取关节位置和时间戳
如果我想使用Kinect传感器实时读取并存储获得的关于骨骼关节的数据/值,我将如何做到这一点 如何将该数据/值保存到一个除非请求新值否则不会更新的变量中。我希望能够将得到的值保存在不同的变量中C# 读取关节位置和时间戳,c#,variables,kinect,kinect-sdk,C#,Variables,Kinect,Kinect Sdk,如果我想使用Kinect传感器实时读取并存储获得的关于骨骼关节的数据/值,我将如何做到这一点 如何将该数据/值保存到一个除非请求新值否则不会更新的变量中。我希望能够将得到的值保存在不同的变量中 任何帮助都将不胜感激。这与保存任何其他变量类型没有什么不同 JointCollection _savedJoint; DateTime _savedJointTime; private void OnSkeletonFrameReady(object sender, SkeletonFrameReady
任何帮助都将不胜感激。这与保存任何其他变量类型没有什么不同
JointCollection _savedJoint;
DateTime _savedJointTime;
private void OnSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame == null || skeletonFrame.SkeletonArrayLength == 0)
return;
// resize the skeletons array if needed
if (_skeletons.Length != skeletonFrame.SkeletonArrayLength)
_skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
// get the skeleton data
skeletonFrame.CopySkeletonDataTo(_skeletons);
foreach (var skeleton in _skeletons)
{
// skip the skeleton if it is not being tracked
if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
continue;
// do other checks and actions if needed...
// save off the joint
_savedJoint = skeleton.Joints[JointType.HandLeft];
_savedJointTime = DateTime.Now;
}
}
}
如果要保存多个关节,可以创建阵列。如果您想将所有内容打包在一起,您可以创建一个存储所有内容的类。您的问题太模糊了,您想做什么(即使在伪代码中)以及什么不起作用?这会不会在每次获得新数据时更新保存的值??我想保留旧数据,例如,第二组数据中的旧数据,以及第五组数据中的旧数据或。。。。。。。。。。。。。。单独保存每组数据,这样,如果我有10帧数据,我会保存10组不同的数据(1到10)。添加
if
语句,仅在特定条件下保存值(例如,if(_counter%5==0)
,每5次更新一次),或者以任何其他方式限制记录的更新数量。或者,使用streamType.OpenNextFrame()
函数轮询3个流中的任意一个流以获得下一个可用帧——设置计时器以决定何时调用它。