我是StackOverflow和Kinect SDK的新手。我目前正在做我最后一年的项目,其中包括来自Kinect的记录/回放颜色/深度和骨架数据。我正在将工具箱与Kinect Toolbox示例项目(颜色/深度/骨架基础C# WPF)集成在一起,以制作一个可以显示先前记录的.replay文件中的所有这些流的程序。
我现在遇到的问题是由于工具箱中的KinectReplay类和SDK中的KinectSensor类的不同。在深度基础示例代码中,为了显示流,WindowLoaded()中的以下行为从Kinect检索的数据分配空间:
/
/ 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数组将被初始化多次,这是低效的,并且在示例代码中,这只会被初始化一次。
发布于 2013-02-19 15:20:27
一种解决方案是在初始化期间简单地获取一帧中的像素数,并始终使用此值,因为记录的帧中的像素数不太可能发生变化。
例如,假设您有一个名为OnNewDepthReplay frame的方法,您将执行如下操作(未经过测试,语法可能关闭):
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 MSDN的video。
https://stackoverflow.com/questions/14864035
复制相似问题