首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用kinect工具箱录制和回放

使用kinect工具箱录制和回放
EN

Stack Overflow用户
提问于 2013-02-14 06:02:40
回答 1查看 1.6K关注 0票数 1

我是StackOverflow和Kinect SDK的新手。我目前正在做我最后一年的项目,其中包括来自Kinect的记录/回放颜色/深度和骨架数据。我正在将工具箱与Kinect Toolbox示例项目(颜色/深度/骨架基础C# WPF)集成在一起,以制作一个可以显示先前记录的.replay文件中的所有这些流的程序。

我现在遇到的问题是由于工具箱中的KinectReplay类和SDK中的KinectSensor类的不同。在深度基础示例代码中,为了显示流,WindowLoaded()中的以下行为从Kinect检索的数据分配空间:

/

代码语言:javascript
复制
/ Allocate space to put the depth pixels we'll receive
this.depthPixels = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];

                // Allocate space to put the color pixels we'll create
                this.colorPixels = new byte[this.sensor.DepthStream.FramePixelDataLength * sizeof(int)];

                // This is the bitmap we'll display on-screen
                this.colorBitmap = new WriteableBitmap(this.sensor.DepthStream.FrameWidth, this.sensor.DepthStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null);

//The code below came from "Skeleton basics C# WPF", which I need to find the correspondence of "CoordinateMapper" in KinectReplay Class 
    // We are not using depth directly, but we do want the points in our 640x480 output resolution.
                 DepthImagePoint depthPoint = this.sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(skelpoint, DepthImageFormat.Resolution640x480Fps30);

在最初的示例代码中,上述对象的大小参数是从KinectSensor对象检索的,我需要做类似的事情,但从KinectReplay对象获取数据,例如,如何从KinectReplay对象获取与“this.replay = new KinectReplay(recordStream);”等效的“this.sensor.DepthStream.FramePixelDataLength”?

我能想到的唯一解决方案是在replay_DepthImageFrameReady(object sender, ReplayDepthImageFrameReadyEventArgs e)中调用“this.depthPixels = new DepthImagePixel[e.FramePixelDataLength];”,每次从KinectReplay接收到深度图像帧时都会调用它。因此,DepthImagePixel数组将被初始化多次,这是低效的,并且在示例代码中,这只会被初始化一次。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-19 15:20:27

一种解决方案是在初始化期间简单地获取一帧中的像素数,并始终使用此值,因为记录的帧中的像素数不太可能发生变化。

例如,假设您有一个名为OnNewDepthReplay frame的方法,您将执行如下操作(未经过测试,语法可能关闭):

代码语言:javascript
复制
public void OnNewDepthReplayFrame(DepthReplayFrameEventArgs e) {
    if (depthPixels == null) {
        depthPixels = new new DepthImagePixel[eFramePixelDataLength];
    }
    // code that uses your depthPixels here
}

但是,使用Kinect 1.5和1.6 SDK附带的录制/重放功能实际上可能比使用Kinect工具箱更好。我曾经使用Kinect Toolbox来录制/重放它,但后来在Kinect for Windows v1.5问世后,我自己转到了Kinect Studio。这里有一个关于如何使用Kinect Studio和guide on MSDNvideo

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14864035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档