存储Kinect 2帧 [英] Storing Kinect 2 Frames

查看:96
本文介绍了存储Kinect 2帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,

我正在尝试将Kinect 2帧存储在缓冲区中,但到目前为止还没有成功。以下是我的想法(问题=>它应该如何工作):

I'm trying to store Kinect 2 frames in a buffer, but with no success thus far. Here are my thoughts (issue => how it should work):

»BodyFrame无法访问body =>需要存储正文;

» BodyFrame doesn't give access to the bodies => need to store the bodies;

»由于我们发送了一个引用=>,因此无法直接存储正文克隆;

» Can't store bodies directly since we're sending a reference => clone;

»克隆数组不会克隆=>内的Body对象按元素克隆元素;

» Cloning the array doesn't clone the Body objects inside => clone element by element;

»Body未实现ICloneable,因此无法访问Clone方法=>创建一个要克隆的模板;

» Body doesn't implement ICloneable, hence not giving access to a Clone method => create a template to clone;

»Body无法序列化=>手动创建Body对象,只需手动复制值;

» Body cannot be serialized => Create Body objects manually and simply copy the values manually;

»Body没有公共结构,并且成员和方法都是readonly => ?

» Body doesn't have public contructors and both members and methods are readonly => ?

无论我尝试什么,它只存储对身体的引用。

No matter what I try, it's only storing the references to the Bodies.

现在,因为我想保留一个框架缓冲区:简单地比较帧之间的状态而不依赖于布尔值和所有这些(我可以简单地等待状态并有一个bool来存储它)。

Now, for the reason why I want to keep a frame buffer: to simply compare states between frames without relying on booleans and all that (I could simply wait for a state and have a bool to store it).

这只是引导我走向VGB但我不知道我真正需要完成的事情是否足够。我试试看。

This is simply leading me towards VGB but I don't know whether it suffices to what I really need to accomplish. I'm giving it a try though.

关于我上面描述的问题的任何想法?我错过了什么或有明显的解决方案吗?

Any thoughts regarding the issues I described above? Am I missing something or is there an obvious solution?

祝你好运,

Apidcloud

Apidcloud

推荐答案

对于正文跟踪,您可以将数据复制到您自己的数据结构中,并且它们与帧无关。有关代码,请参阅BodyBasics,在这两个实例中,这些正文对象是使用GetAndRefreshBodyData时的数据副本:
For body tracking you copy the data to your own data structures and they are independent of the frame. See BodyBasics for code, in both instance these body objects are copies of the data when using GetAndRefreshBodyData :
c#:
private Body[] bodies = null;

using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame())
{
    if (bodyFrame != null)
    {
        if (this.bodies == null)
        {
            this.bodies = new Body[bodyFrame.BodyCount];
        }

        // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
        // As long as those body objects are not disposed and not set to null in the array,
        // those body objects will be re-used.
        bodyFrame.GetAndRefreshBodyData(this.bodies);
        dataReceived = true;
    }
}

c++:
IBody* ppBodies[BODY_COUNT] = {0};
HRESULT hr = pBodyFrame->GetAndRefreshBodyData(_countof(ppBodies), ppBodies);


如果你试图将这个存储离线并且内存不足,那么你只需要创建一个简单的Body结构并存储Joint和JointOrientation数据,这些是结构你可以序列化。

If you are trying to store this offline and out of memory, then you will just need to create a simple Body structure and store the Joint and JointOrientation data and those are structures you can serialize.


这篇关于存储Kinect 2帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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