如何测量ARCore Android应用的帧率?

huangapple go评论84阅读模式
英文:

How to measure the frame rate of an ARCore Android app?

问题

我正在使用HelloAR示例应用程序。该示例使用ARCore。我在Android三星Galaxy Tab S5e上运行该示例。

我应该如何测量我的AR应用程序的帧率(每秒帧数)?我需要绘制数据,所以理论上,无论我采取什么方法,输出都应该给我一些类似CSV的东西,比如时间,帧率。

我尝试过查看GameBench,但那要求我填写一个表格,然后等待一个“专家”与我联系... 我也尝试过使用带有framestats的dumpsys,但那只输出2帧并且很少更新。我还尝试过一些来自GitHub的项目(TinyDancer),但那个不起作用。

有什么想法吗?

英文:

I am using the HelloAR sample application. The sample uses ARCore. I am running the sample on an Android Samsung Galaxy Tab S5e.

How can I measure the framerate (Frames Per Second) of my AR app? I need to graph the data, so ideally the output of whatever approach I take will give me some sort of CSV e.g. time,fps

I've tried looking at GameBench, but that requires me to fill out a form and wait for a "specialist" to get back to me... I have also tried dumpsys with framestats, but that only outputs 2 frames and very seldom updates. I have also tried some projects from GitHub (TinyDancer), but that does not work.

Any ideas?

答案1

得分: 1

在ARCore 1.19中,您可以使用Frame公共类的getTimestamp()公共方法来测量帧率。在60fps的情况下,每帧大约持续16.67毫秒(或**~16670000纳秒**)。

public long getTimestamp()

让我们来看看官方的文档说了什么:

> **getTimestamp()**方法以纳秒为单位返回捕获此图像时的时间戳。这可以用于检测丢帧或测量相机帧率。此值的时间基础没有明确定义,但可能类似于System.nanoTime()

因此,如果每个当前帧与前一帧之间的时间差约为16670000纳秒,则帧率为60fps。但如果时间差为约33330000纳秒,则帧率为30fps。

英文:

For measuring frame rate in ARCore 1.19 you can use getTimestamp() public method of a public class Frame. At 60 fps, every frame lasts approximately 16.67 ms (or ~16670000 ns).

public long getTimestamp()

Let's see what official documentation says:

>getTimestamp() method returns the timestamp in nanoseconds when this image was captured. This can be used to detect dropped frames or measure the camera frame rate. The time base of this value is specifically not defined, but it is likely similar to System.nanoTime().

So, if a time difference between each current and previous frame is ~16670000 nanosec, frame rate is 60 fps. But if a time difference is ~33330000 nanosec, then frame rate is 30 fps.

huangapple
  • 本文由 发表于 2020年9月3日 03:35:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63712483.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定