本文整理汇总了Python中pygaze.screen.Screen.draw_fixation方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.draw_fixation方法的具体用法?Python Screen.draw_fixation怎么用?Python Screen.draw_fixation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygaze.screen.Screen
的用法示例。
在下文中一共展示了Screen.draw_fixation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
scr.draw_text(text="Press Space to start")
disp.fill(scr)
disp.show()
kb.get_key(keylist=['space'], timeout=None, flush=True)
# # # # #
# VALIDATION
# loop through points
for i in range(len(CALIBPOINTS)):
# get coordinate
x, y = CALIBPOINTS[i]
# draw calibration point
scr.clear()
scr.draw_fixation(fixtype='dot', pos=(x,y))
disp.fill(scr)
# start recording
tracker.start_recording()
tracker.log("VALIDATION_TRIALSTART, trialnr=%d, x=%d, y=%d" % (i,x,y))
# show display
disp.show()
tracker.log("validation_point_on")
# allow for a bit of time so the subject can fixate the target
clock.pause(1000)
tracker.log("validation_point_fix")
# wait for a bit
clock.pause(POINTTIME)
# clear screen
scr.clear()
disp.fill(scr)
示例2: EyelinkGraphics
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
#.........这里部分代码省略.........
self.clear_cal_display()
def record_abort_hide(self):
"""TODO: What does this do?"""
pass
def clear_cal_display(self):
"""Clears the calibration display"""
self.display.fill()
self.display.show()
def erase_cal_target(self):
"""TODO: What does this do?"""
self.clear_cal_display()
def draw_cal_target(self, x, y):
"""
Draws calibration target.
Arguments:
x -- The X coordinate of the target.
y -- The Y coordinate of the target.
"""
self.play_beep(pylink.CAL_TARG_BEEP)
self.screen.clear()
self.screen.draw_fixation(fixtype="dot", pos=(x, y))
self.display.fill(screen=self.screen)
self.display.show()
def play_beep(self, beepid):
"""
Plays a sound.
Arguments:
beepid -- A number that identifies the sound.
"""
if beepid == pylink.CAL_TARG_BEEP:
# For some reason, playing the beep here doesn't work, so we have
# to play it when the calibration target is drawn.
if EYELINKCALBEEP:
self.__target_beep__.play()
elif beepid == pylink.CAL_ERR_BEEP or beepid == pylink.DC_ERR_BEEP:
# show a picture
self.screen.clear()
self.screen.draw_text(
text="calibration lost, press 'Enter' to return to menu",
pos=(self.xc, self.yc),
center=True,
font="mono",
fontsize=self.fontsize,
antialias=True,
)
self.display.fill(self.screen)
self.display.show()
# play beep
self.__target_beep__error__.play()
示例3: libeyelink
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
#.........这里部分代码省略.........
def calibrate(self):
"""See pygaze._eyetracker.baseeyetracker.BaseEyeTracker"""
if self.recording:
raise Exception(
"Error in libeyelink.libeyelink.calibrate(): Trying to "
"calibrate after recording has started!")
# # # # #
# EyeLink calibration and validation
# attempt calibrate; confirm abort when esc pressed
while True:
self.eyelink_graphics.esc_pressed = False
pylink.getEYELINK().doTrackerSetup()
if not self.eyelink_graphics.esc_pressed:
break
self.confirm_abort_experiment()
# If we are using the built-in EyeLink event detection, we don't need
# the RMS calibration routine.
if self.eventdetection == 'native':
return
# # # # #
# RMS calibration
# present instructions
self.display.fill() # clear display
self.scr.draw_text(text= \
"Noise calibration: please look at the dot\n\n(press space to start)",
pos=(self.resolution[0]/2, int(self.resolution[1]*0.2)),
center=True, fontsize=self.fontsize)
self.scr.draw_fixation(fixtype='dot')
self.display.fill(self.scr)
self.display.show()
self.scr.clear() # clear screen again
# wait for spacepress
self.kb.get_key(keylist=['space'], timeout=None)
# start recording
self.log("PYGAZE RMS CALIBRATION START")
self.start_recording()
# show fixation
self.display.fill()
self.scr.draw_fixation(fixtype='dot')
self.display.fill(self.scr)
self.display.show()
self.scr.clear()
# wait for a bit, to allow participant to fixate
clock.pause(500)
# get samples
# samplelist, prefilled with 1 sample to prevent sl[-1] from producing
# an error; first sample will be ignored for RMS calculation
sl = [self.sample()]
t0 = clock.get_time() # starting time
while clock.get_time() - t0 < 1000:
s = self.sample() # sample
if s != sl[-1] and s != (-1, -1) and s != (0, 0):
sl.append(s)
# stop recording
示例4: EyeTribeTracker
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
#.........这里部分代码省略.........
self.screen.clear()
self.screen.draw_text("Calibration aborted. Press Space to restart, or 'Q' to quit.")
self.disp.fill(self.screen)
self.disp.show()
# get input
key, keytime = self.kb.get_key(keylist=['q','space'], timeout=None, flush=True)
if key == 'space':
# unset quited Boolean
quited = False
# skip further processing
continue
# get the calibration result if it was not obtained yet
if type(calibresult) != dict:
# empty display
self.disp.fill()
self.disp.show()
# allow for a bit of calculation time
clock.pause(2000)
# get the result
calibresult = self.eyetribe._tracker.get_calibresult()
# results
# clear the screen
self.screen.clear()
# draw results for each point
if type(calibresult) == dict:
for p in calibresult['calibpoints']:
# only draw the point if data was obtained
if p['state'] > 0:
# draw the mean error
self.screen.draw_circle(colour=(252,233,79), pos=(p['cpx'],p['cpy']), r=p['mepix'], pw=0, fill=True)
# draw the point
self.screen.draw_fixation(fixtype='dot', colour=(115,210,22), pos=(p['cpx'],p['cpy']))
# draw the estimated point
self.screen.draw_fixation(fixtype='dot', colour=(32,74,135), pos=(p['mecpx'],p['mecpy']))
# annotate accuracy
self.screen.draw_text(text=str(p['acd']), pos=(p['cpx']+10,p['cpy']+10), fontsize=12)
# if no data was obtained, draw the point in red
else:
self.screen.draw_fixation(fixtype='dot', colour=(204,0,0), pos=(p['cpx'],p['cpy']))
# draw box for averages
self.screen.draw_rect(colour=(238,238,236), x=int(self.dispsize[0]*0.15), y=int(self.dispsize[1]*0.2), w=400, h=200, pw=0, fill=True)
# draw result
if calibresult['result']:
self.screen.draw_text(text="calibration is successful", colour=(115,210,22), pos=(int(self.dispsize[0]*0.25),int(self.dispsize[1]*0.25)), fontsize=12)
else:
self.screen.draw_text(text="calibration failed", colour=(204,0,0), pos=(int(self.dispsize[0]*0.25),int(self.dispsize[1]*0.25)), fontsize=12)
# draw average accuracy
self.screen.draw_text(text="average error = %.2f degrees" % (calibresult['deg']), colour=(211,215,207), pos=(int(self.dispsize[0]*0.25),int(self.dispsize[1]*0.25+20)), fontsize=12)
# draw input options
self.screen.draw_text(text="Press Space to continue, or 'R' to restart.", colour=(211,215,207), pos=(int(self.dispsize[0]*0.25),int(self.dispsize[1]*0.25+40)), fontsize=12)
else:
self.screen.draw_text(text="Calibration failed, press 'R' to try again.")
# show the results
self.disp.fill(self.screen)
self.disp.show()
# wait for input
key, keytime = self.kb.get_key(keylist=['space','r'], timeout=None, flush=True)
# process input
if key == 'space':
calibrated = True
# calibration failed if the user quited
if quited:
return False
示例5: SMItracker
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
#.........这里部分代码省略.........
# calibrate
cres = iViewXAPI.iV_Calibrate()
# validate if calibration returns succes
if cres == 1:
cerr = None
vres = iViewXAPI.iV_Validate()
# handle validation errors
if vres != 1:
verr = errorstring(vres)
else:
verr = None
## # TEST #
## res = iViewXAPI.iV_GetAccuracyImage(byref(imageData))
## self.log("IMAGEBUFFERSTART")
## self.log(imageData.imageBuffer)
## self.log("IMAGEBUFFERSTOP")
## print("Image height: %s, image width: %s, image size: %s" % (imageData.imageHeight,imageData.imageWidth, imageData.imageSize))
## print imageData.imageBuffer
## ########
# handle calibration errors
else:
cerr = errorstring(cres)
# return succes
if cerr == None:
print("libsmi.SMItracker.calibrate: calibration was succesful")
if verr == None:
print("libsmi.SMItracker.calibrate: validation was succesful")
# present instructions
self.disp.fill() # clear display
self.screen.draw_text(text="Noise calibration: please look at the dot\n\n(press space to start)", pos=(self.dispsize[0]/2, int(self.dispsize[1]*0.2)), center=True)
self.screen.draw_fixation(fixtype='dot')
self.disp.fill(self.screen)
self.disp.show()
self.screen.clear() # clear screen again
# wait for spacepress
self.kb.get_key(keylist=['space'], timeout=None)
# show fixation
self.disp.fill()
self.screen.draw_fixation(fixtype='dot')
self.disp.fill(self.screen)
self.disp.show()
self.screen.clear()
# wait for a bit, to allow participant to fixate
clock.pause(500)
# get samples
sl = [self.sample()] # samplelist, prefilled with 1 sample to prevent sl[-1] from producing an error; first sample will be ignored for RMS calculation
t0 = clock.get_time() # starting time
while clock.get_time() - t0 < 1000:
s = self.sample() # sample
if s != sl[-1] and s != (-1,-1) and s != (0,0):
sl.append(s)
# calculate RMS noise
Xvar = []
Yvar = []
for i in range(2,len(sl)):
Xvar.append((sl[i][0]-sl[i-1][0])**2)
Yvar.append((sl[i][1]-sl[i-1][1])**2)
XRMS = (sum(Xvar) / len(Xvar))**0.5
YRMS = (sum(Yvar) / len(Yvar))**0.5
示例6:
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
scr.draw_text("There should be two polygons on the screen: \
\nred filled triangle on the left, and green unfilled hexagon on the right", pos=(DISPSIZE[0]/2, DISPSIZE[1]/4))
pl = [(DISPSIZE[0]*0.25, DISPSIZE[1]*0.45), (DISPSIZE[0]*0.2, DISPSIZE[1]*0.55), (DISPSIZE[0]*0.3, DISPSIZE[1]*0.55)]
scr.draw_polygon(pl, colour=(255,0,0), pw=5, fill=True)
# topleft, topright, centreright, bottomright, bottomleft, centreleft
pl = [(DISPSIZE[0]*0.70, DISPSIZE[1]*0.40), (DISPSIZE[0]*0.80, DISPSIZE[1]*0.40), (DISPSIZE[0]*0.85, DISPSIZE[1]*0.5), (DISPSIZE[0]*0.80, DISPSIZE[1]*0.60), (DISPSIZE[0]*0.70, DISPSIZE[1]*0.60), (DISPSIZE[0]*0.65, DISPSIZE[1]*0.5)]
scr.draw_polygon(pl, colour=(0,255,0), pw=5, fill=False)
disp.fill(scr)
disp.show()
kb.get_key()
#scr.draw_fixation()
scr.clear()
scr.draw_text("There should be three fixation targets on the screen: \
\nred cross on the left, green X in the centre, and blue dot on the right", pos=(DISPSIZE[0]/2, DISPSIZE[1]/4))
scr.draw_fixation(fixtype='cross', colour=(255,0,0), pos=(DISPSIZE[0]*0.25,DISPSIZE[1]/2), pw=3, diameter=15)
scr.draw_fixation(fixtype='x', colour=(0,255,0), pos=(DISPSIZE[0]/2,DISPSIZE[1]/2), pw=3, diameter=15)
scr.draw_fixation(fixtype='dot', colour=(0,0,255), pos=(DISPSIZE[0]*0.75,DISPSIZE[1]/2), pw=3, diameter=15)
disp.fill(scr)
disp.show()
kb.get_key()
#scr.draw_image()
scr.clear()
scr.draw_text("There should be an image in the centre of the screen", pos=(DISPSIZE[0]/2, DISPSIZE[1]/10))
scr.draw_image(imagefile)
disp.fill(scr)
disp.show()
kb.get_key()
#scr.set_background_colour()
示例7: range
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
# # # # #
# VALIDATION horizontal
scr.clear()
scr.draw_line((0,0,0), (int(0.05*DISPSIZE[0]),int(0.15*DISPSIZE[1])), (int(0.95*DISPSIZE[0]),int(0.15*DISPSIZE[1])), 1)
scr.draw_line((0,0,0), (int(0.95*DISPSIZE[0]),int(0.15*DISPSIZE[1])), (int(0.95*DISPSIZE[0]),int(0.5*DISPSIZE[1])), 1)
scr.draw_line((0,0,0), (int(0.95*DISPSIZE[0]),int(0.5*DISPSIZE[1])), (int(0.05*DISPSIZE[0]),int(0.5*DISPSIZE[1])), 1)
scr.draw_line((0,0,0), (int(0.05*DISPSIZE[0]),int(0.5*DISPSIZE[1])), (int(0.05*DISPSIZE[0]),int(0.85*DISPSIZE[1])), 1)
scr.draw_line((0,0,0), (int(0.05*DISPSIZE[0]),int(0.85*DISPSIZE[1])), (int(0.95*DISPSIZE[0]),int(0.85*DISPSIZE[1])), 1)
# loop through points
for i in range(len(CALIBPOINTShor)):
# get coordinate
x, y = CALIBPOINTShor[i]
# draw calibration point
scr.draw_fixation(fixtype='cross', pos=(x,y))
disp.fill(scr)
disp.show()
# loop through points
for i in range(len(CALIBPOINTShor)):
# get coordinate
x, y = CALIBPOINTShor[i]
# draw calibration point
#scr.clear()
scr.draw_fixation(fixtype='dot', colour = (255,255,255), pos=(x,y))
disp.fill(scr)
# start recording
tracker.start_recording()
示例8: EyelinkGraphics
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
#.........这里部分代码省略.........
self.clear_cal_display()
def record_abort_hide(self):
"""TODO: What does this do?"""
pass
def clear_cal_display(self):
"""Clears the calibration display"""
self.display.fill()
self.display.show()
def erase_cal_target(self):
"""TODO: What does this do?"""
self.clear_cal_display()
def draw_cal_target(self, x, y):
"""
Draws calibration target.
Arguments:
x -- The X coordinate of the target.
y -- The Y coordinate of the target.
"""
self.play_beep(pylink.CAL_TARG_BEEP)
self.screen.clear()
self.screen.draw_fixation(fixtype='dot', pos=(x,y))
self.display.fill(screen=self.screen)
self.display.show()
def play_beep(self, beepid):
"""
Plays a sound.
Arguments:
beepid -- A number that identifies the sound.
"""
if beepid == pylink.CAL_TARG_BEEP:
# For some reason, playing the beep here doesn't work, so we have
# to play it when the calibration target is drawn.
if EYELINKCALBEEP:
self.__target_beep__.play()
elif beepid == pylink.CAL_ERR_BEEP or beepid == pylink.DC_ERR_BEEP:
# show a picture
self.screen.clear()
self.screen.draw_text(text= \
"calibration lost, press 'q' to return to menu", pos= \
(self.xc,self.yc), center=True, font='mono', fontsize=12, \
antialias=True)
self.display.fill(self.screen)
self.display.show()
# play beep
self.__target_beep__error__.play()
elif beepid == pylink.CAL_GOOD_BEEP:
self.screen.clear()
if self.state == "calibration":
self.screen.draw_text(text= \
示例9:
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
scr.draw_text("The dot should follow your eye movements")
disp.fill(scr)
disp.show()
tracker.log("now testing sample function")
tracker.status_msg("now testing sample function")
tracker.start_recording()
key = None
while not key == 'space':
# get new key
key, presstime = kb.get_key(timeout=1)
# new states
gazepos = tracker.sample()
# draw to screen
scr.clear()
scr.draw_text("The dot should follow your eye movements")
scr.draw_fixation(fixtype='dot', pos=gazepos, pw=3, diameter=15)
disp.fill(scr)
disp.show()
tracker.stop_recording()
scr.clear()
# tracker.drift_correction
scr.clear()
scr.draw_text("Next is a drift check. Press Space to start!")
disp.fill(scr)
disp.show()
kb.get_key()
tracker.drift_correction()
# tracker.fix_triggered_drift_correction
scr.clear()
示例10: Dummy
# 需要导入模块: from pygaze.screen import Screen [as 别名]
# 或者: from pygaze.screen.Screen import draw_fixation [as 别名]
#.........这里部分代码省略.........
# function assumes a 'fixation' has started when 'gaze' position remains reasonably
# stable for five samples in a row (same as saccade end)
maxerr = 3 # pixels
# wait for reasonably stable position
xl = [] # list for last five samples (x coordinate)
yl = [] # list for last five samples (y coordinate)
moving = True
while moving:
npos = self.sample()
xl.append(npos[0]) # add newest sample
yl.append(npos[1]) # add newest sample
if len(xl) == 5:
# check if deviation is small enough
if max(xl)-min(xl) < maxerr and max(yl)-min(yl) < maxerr:
moving = False
# remove oldest sample
xl.pop(0); yl.pop(0)
# wait for a bit, to avoid immediately returning (runs go faster than mouse moves)
clock.pause(10)
return clock.get_time(), (xl[len(xl)-1],yl[len(yl)-1])
def wait_for_fixation_end(self):
"""Returns time and gaze position when a simulated fixation is ended"""
# function assumes that a 'fixation' has ended when a deviation of more than maxerr
# from the initial 'fixation' position has been detected (using Pythagoras, ofcourse)
stime, spos = self.wait_for_fixation_start()
maxerr = 3 # pixels
while True:
npos = self.sample() # get newest sample
if ((spos[0]-npos[0])**2 + (spos[1]-npos[1])**2)**0.5 > maxerr: # Pythagoras
break
return clock.get_time(), spos
def wait_for_blink_start(self):
"""Returns starting time and position of a simulated blink (mousebuttondown)"""
# blinks are simulated with mouseclicks: a right mouseclick simulates the closing
# of the eyes, a mousebuttonup the opening.
while not self.blinking:
pos = self.sample()
return clock.get_time(), pos
def wait_for_blink_end(self):
"""Returns ending time and position of a simulated blink (mousebuttonup)"""
# blinks are simulated with mouseclicks: a right mouseclick simulates the closing
# of the eyes, a mousebuttonup the opening.
# wait for blink start
while not self.blinking:
spos = self.sample()
# wait for blink end
while self.blinking:
epos = self.sample()
return clock.get_time(), epos
def set_draw_drift_correction_target_func(self, func):
"""See pygaze._eyetracker.baseeyetracker.BaseEyeTracker"""
self.draw_drift_correction_target = func
# ***
#
# Internal functions below
#
# ***
def draw_drift_correction_target(self, x, y):
"""
Draws the drift-correction target.
arguments
x -- The X coordinate
y -- The Y coordinate
"""
self.screen.clear()
self.screen.draw_fixation(fixtype='dot', colour=settings.FGC, \
pos=(x,y), pw=0, diameter=12)
self.display.fill(self.screen)
self.display.show()