中接收到的图像事件计算FPS

中接收到的图像事件计算FPS

本文介绍了根据C#中接收到的图像事件计算FPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我从串行端口&我将构建图像数据包&在C#中引发收到的图片事件.现在,我想知道我每秒收到多少张图像( FPS - F rame  P er S 第二).

I receive bytes from serial port & I will construct Image packet & rise a Image received Event in C#. Now, I want to know how many Images I'm receiving per second (FPS-Frame Per Second).

我尝试了秒表课程

Stopwatch st = Stopwatch();
int FPScount = 0;
double prevMilliSec = 0;
double currentMilliSec = 0;

私有无效serial_ImageDataReceived(对象发送者,ImageData e){ 如果(st.IsRunning) { st.Start(); FPSwatch = true; } 别的 { TimeSpan ts =经过的时间; currentMilliSec + = ts.TotalMilliseconds-prevMilliSec; prevMilliSec = ts.TotalMilliseconds; FPScount + = 1; 如果(currentMilliSec> = 1000.0f) { text_string + ="FPS:" + FPScount.ToString()+""+""MilliSeconds:" + currentMilliSec.ToString()+"\ r \ n"; FPScount = 0; currentMilliSec = 0; } }}

private void serial_ImageDataReceived(object sender, ImageData e){ if (st.IsRunning) { st.Start(); FPSwatch = true; } else { TimeSpan ts = st.Elapsed; currentMilliSec += ts.TotalMilliseconds - prevMilliSec; prevMilliSec = ts.TotalMilliseconds; FPScount += 1; if (currentMilliSec >= 1000.0f) { text_string += "FPS: "+FPScount.ToString()+" "+ "MilliSeconds:" + currentMilliSec.ToString() + "\r\n"; FPScount = 0; currentMilliSec = 0; } }}

如果我打印文本字符串,则会得到以下信息:

If i print text_string, I get the following:

FPS:13百万秒:1029.1345
FPS:13&MilliSeconds:1033.2451
FPS:13&MilliSeconds:1038.7088
FPS:13&MilliSeconds:1034.3744
FPS:13&MilliSeconds:1036.5768
FPS:13&MilliSeconds:1036.3706
FPS:13&MilliSeconds:1028.3304
FPS:13&MilliSeconds:1034.6186
FPS:13&MilliSeconds:1031.7196
FPS:13&MilliSeconds:1028.2347
FPS:13&MilliSeconds:1026.7377

FPS: 13  MilliSeconds:1029.1345
FPS: 13  MilliSeconds:1033.2451
FPS: 13  MilliSeconds:1038.7088
FPS: 13  MilliSeconds:1034.3744
FPS: 13  MilliSeconds:1036.5768
FPS: 13  MilliSeconds:1036.3706
FPS: 13  MilliSeconds:1028.3304
FPS: 13  MilliSeconds:1034.6186
FPS: 13  MilliSeconds:1031.7196
FPS: 13  MilliSeconds:1028.2347
FPS: 13  MilliSeconds:1026.7377

从秒表时间信息中计算FPS的这种精确方法是吗?

Is this accurate way of doing to calculate FPS from the Stopwatch time info ?

谢谢

推荐答案

 欢迎使用MSDN论坛支持.

  Welcome to MSDN Forum Support.

  我们正在对此问题进行研究.我们可能需要一些时间才能回复您.

  We're doing research on this issue. It might take some time before we get back to you.

 真诚的

 贾森·王(Jason Wang)

  Jason Wang




这篇关于根据C#中接收到的图像事件计算FPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 05:14