I'm new in Vizard. I'm trying to create a simple code to perform two tasks sequentially for a specific time set:
A black image for 0.8 seconds
A sequence of images (from a folder) taken randomly, for 1.5 seconds. I can perform these task separately, but I can't merge together. Suggestions are very appreciated, thank you
Code:
import viz
import vizact
import vizinfo
import random
viz.setMultiSample(4)
viz.fov(60)
viz.go()
vizinfo.InfoPanel()
viz.clearcolor(viz.BLACK)
FRAME_RATE = 0.667 # in Hertz
r = list(range(7))
random.shuffle(r)
movieImages = viz.cycle( [ viz.addTexture('sequence_IMG/img%d.jpg' % i) for i in r ] )
screen = viz.addTexQuad()
screen.setPosition([0, 1.82, 1.5])
screen.setScale([4.0/3, 1, 1])
def executeExperiment():
for trialNumber in range(3):
yield Dark() #wait for doTrial to finish
yield vizact.ontimer(1.0/FRAME_RATE, NextMovieFrame)
print('Trial Done: ', trialNumber)
print('done with experiment')
#Setup timer to swap texture at specified frame rate
def NextMovieFrame():
screen.texture(movieImages.next())
def Dark():
yield viztask.waitTime(1) #wait for 1 second
viz.clearcolor(viz.BLACK)
vizact.ontimer(1.0/FRAME_RATE, NextMovieFrame)
viztask.schedule(executeExperiment())