【问题标题】:Kinect V2- Saving Body DataKinect V2-保存身体数据
【发布时间】:2016-03-16 02:57:08
【问题描述】:

我正在使用 Kinect V2 SDK 用 C# 编写程序,并正在努力记录身体数据。我试图将 BodyFrame 保存到一个文件中,但它不是可序列化的,Body 类也不是。实现这一目标的最佳方法是什么?我目前的想法是在每一帧中保存每个身体中每个关节的位置数据,但我有一种感觉会很快变得复杂。建议?我在下面附上了微软的部分 BodyBasics 示例代码,它将身体数据分解成关节。谢谢!

if (body.IsTracked)
{
     //this.DrawClippedEdges(body, dc);
     IReadOnlyDictionary<JointType, Joint> joints = body.Joints;

     // convert the joint points to depth (display) space
     Dictionary<JointType, Point> jointPoints = new Dictionary<JointType, Point>();

     foreach (JointType jointType in joints.Keys)
     {
         // sometimes the depth(Z) of an inferred joint may show as negative
         // clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity)
         CameraSpacePoint position = joints[jointType].Position;
         if (position.Z < 0)
         {
             position.Z = InferredZPositionClamp;
         }

         DepthSpacePoint depthSpacePoint = this.coordinateMapper.MapCameraPointToDepthSpace(position);
         jointPoints[jointType] = new Point(depthSpacePoint.X, depthSpacePoint.Y);
      } 

【问题讨论】:

    标签: c# kinect kinect-sdk


    【解决方案1】:

    使用JSON.net

    static List<Body> trackedBodies = new List<Body>();
    trackedBodies = bodies.Where(b => b.IsTracked == true).ToList();
    if (trackedBodies.Count() < 1)
        return null;
    string kinectBodyDataString = JsonConvert.SerializeObject(trackedBodies);
    

    【讨论】:

    • 即使 Body 类不可序列化,它还能工作吗?
    猜你喜欢
    • 2016-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-13
    • 2018-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多