我有一个计数器工作,它计算每一帧。我要做的是将时间除以确定程序的FPS。但是我不确定如何在python中对计时功能执行操作。
我尝试初始化时间为
fps_time = time.time
fps_time = float(time.time)
fps_time = np.float(time.time)
fps_time = time()
然后计算fps
FPS = (counter / fps_time)
FPS = float(counter / fps_time)
FPS = float(counter (fps_time))
但是我得到的错误是对象不可调用或不支持/的操作数:'int'和'buildin functions'
先谢谢您的帮助!
最佳答案
import time
while True:
start_time = time.time() # start time of the loop
########################
# your fancy code here #
########################
print("FPS: ", 1.0 / (time.time() - start_time)) # FPS = 1 / time to process loop
import time
start_time = time.time()
x = 1 # displays the frame rate every 1 second
counter = 0
while True:
########################
# your fancy code here #
########################
counter+=1
if (time.time() - start_time) > x :
print("FPS: ", counter / (time.time() - start_time))
counter = 0
start_time = time.time()
希望能帮助到你!
关于python - fps-如何将时间除以计数功能以确定fps,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43761004/