运行加载ci时在Psycopy(python)中丢弃过多帧

2024-06-23 19:00:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python和psycpy的新手,我已经编程了一个“加载循环”,不幸的是我掉了太多的帧。我使用的是60赫兹的刷新率,全屏,没有互联网连接,而且电脑(MacBookPro)功能强大。可能是我的代码出了问题(可能是在每一帧中调用的setVertices方法),有人能告诉我是否是这样的情况,以及在精神病学中是否有其他方法来画一个加载圆(不掉太多帧)? 谢谢 伊曼纽尔

from psychopy import visual,event
import numpy
import math

mywin = visual.Window([1280, 800],monitor="testMonitor",units="deg",fullscr = True,winType='pyglet')
cir = visual.ShapeStim(mywin,lineWidth = 4,lineColor = 'black',closeShape = False)

class circ(object):
    def __init__(self,rad,size,centre):
        self.rad = rad
        self.size = size
        self.centre = centre
        self.points = numpy.arange(0,self.size, dtype = numpy.float)
def make_circle(self):
        self.cx = self.centre[0]+(self.rad*numpy.cos(self.points*math.pi/(self.size/2)))
        self.cy = self.centre[1]+(self.rad*numpy.sin(self.points*math.pi/(self.size/2)))
        return numpy.array([self.cx,self.cy])

nFrames = 240       
c = circ(3,nFrames,(0,0))
frames = numpy.zeros((nFrames,1),float)
coord = c.make_circle()
newpos=[]

for iframe in range(nFrames):
    newpos.append([coord[0,iframe],coord[1,iframe]])
    cir.setVertices(newpos)
    cir.draw()
    frames[iframe] = mywin.flip()
print numpy.diff(frames,axis = 0)*1000

Tags: importselfnumpysizeframesmathpointsiframe

热门问题