C# kinect数据采集fps>;30
我正试图为kinect的深度采集计算fps 为datetime实现的深度计算fps 我获得了>60 fps的速度,而且有时会达到难以置信的无穷大C# kinect数据采集fps>;30,c#,kinect,frame-rate,C#,Kinect,Frame Rate,我正试图为kinect的深度采集计算fps 为datetime实现的深度计算fps 我获得了>60 fps的速度,而且有时会达到难以置信的无穷大 虽然kinect给出了30 fps为什么我得到无穷大,但我做错了什么?您必须测量每次调用函数之间的间隔,而不是函数执行所需的时间。大概是这样的: static DateTime lastFrame = DateTime.Now; private void DepthImageReady(object sender, DepthImageFrameRea
虽然kinect给出了30 fps为什么我得到无穷大,但我做错了什么?您必须测量每次调用函数之间的间隔,而不是函数执行所需的时间。大概是这样的:
static DateTime lastFrame = DateTime.Now;
private void DepthImageReady(object sender, DepthImageFrameReadyEventArgs e)
{
using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
{
if (depthFrame != null)
{
depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);
}
else
{
// depthFrame is null because the request did not arrive in time
}
}
var now = DateTime.Now;
TimeSpan result = now.Subtract(lastFrame);
lastFrame = now;
var milliseconds = result.TotalMilliseconds;
this.Text = "Kinect (" + (1000.0 / milliseconds) + "fps)";
}
由于AlexDev给了您一个解决方案,我删除了您的问题“查看您的代码,DateTime之前和之后的变量都设置为DateTime。现在-以秒为单位的差值将为0。无穷大是被零除的结果。”@PaulF TotalSeconds是双精度。我根据你的评论编辑了答案,我想我会留下它,因为它可能更精确。是的-我的错误你是对的-我在看秒属性,它是一个int。@AlexDev在这里使用double或var会有很大的不同吗?一点也不。因为TotalMillimess返回一个双精度
var,所以毫秒将定义为双精度。@AlexDev你能帮我理解什么是帧吗?采集(kinect)+处理(更改RGB值)+显示=1帧还是处理+投影=1帧?
static DateTime lastFrame = DateTime.Now;
private void DepthImageReady(object sender, DepthImageFrameReadyEventArgs e)
{
using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
{
if (depthFrame != null)
{
depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);
}
else
{
// depthFrame is null because the request did not arrive in time
}
}
var now = DateTime.Now;
TimeSpan result = now.Subtract(lastFrame);
lastFrame = now;
var milliseconds = result.TotalMilliseconds;
this.Text = "Kinect (" + (1000.0 / milliseconds) + "fps)";
}