本文整理汇总了Python中psychopy.clock.Clock.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Clock.reset方法的具体用法?Python Clock.reset怎么用?Python Clock.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psychopy.clock.Clock
的用法示例。
在下文中一共展示了Clock.reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MovieStim3
# 需要导入模块: from psychopy.clock import Clock [as 别名]
# 或者: from psychopy.clock.Clock import reset [as 别名]
class MovieStim3(BaseVisualStim, ContainerMixin):
"""A stimulus class for playing movies (mpeg, avi, etc...) in PsychoPy
that does not require avbin. Instead it requires the cv2 python package
for OpenCV. The VLC media player also needs to be installed on the
psychopy computer.
**Example**::
See Movie2Stim.py for demo.
"""
def __init__(self, win,
filename="",
units='pix',
size=None,
pos=(0.0,0.0),
ori=0.0,
flipVert=False,
flipHoriz=False,
color=(1.0,1.0,1.0),
colorSpace='rgb',
opacity=1.0,
volume=1.0,
name='',
loop=False,
autoLog=True,
depth=0.0,
noAudio=False,
vframe_callback=None,
fps=None,
interpolate = True,
):
"""
:Parameters:
filename :
a string giving the relative or absolute path to the movie.
flipVert : True or *False*
If True then the movie will be top-bottom flipped
flipHoriz : True or *False*
If True then the movie will be right-left flipped
volume :
The nominal level is 100, and 0 is silence.
loop : bool, optional
Whether to start the movie over from the beginning if draw is
called and the movie is done.
"""
# what local vars are defined (these are the init params) for use
# by __repr__
self._initParams = dir()
self._initParams.remove('self')
super(MovieStim3, self).__init__(win, units=units, name=name,
autoLog=False)
retraceRate = win._monitorFrameRate
if retraceRate is None:
retraceRate = win.getActualFrameRate()
if retraceRate is None:
logging.warning("FrameRate could not be supplied by psychopy; defaulting to 60.0")
retraceRate = 60.0
self._retraceInterval = 1.0/retraceRate
self.filename = filename
self.loop = loop
self.flipVert = flipVert
self.flipHoriz = flipHoriz
self.pos = numpy.asarray(pos, float)
self.depth = depth
self.opacity = float(opacity)
self.interpolate = interpolate
self.noAudio = noAudio
self._audioStream = None
self.useTexSubImage2D = True
self._videoClock = Clock()
self.loadMovie(self.filename)
self.setVolume(volume)
self.nDroppedFrames = 0
#size
if size is None:
self.size = numpy.array([self._mov.w, self._mov.h],
float)
else:
self.size = val2array(size)
self.ori = ori
self._updateVertices()
#set autoLog (now that params have been initialised)
self.autoLog = autoLog
if autoLog:
logging.exp("Created %s = %s" %(self.name, str(self)))
def reset(self):
self._numpyFrame = None
self._nextFrameT = None
self._texID = None
self.status = NOT_STARTED
def setMovie(self, filename, log=True):
"""See `~MovieStim.loadMovie` (the functions are identical).
This form is provided for syntactic consistency with other visual stimuli.
#.........这里部分代码省略.........
示例2: MovieStim2
# 需要导入模块: from psychopy.clock import Clock [as 别名]
# 或者: from psychopy.clock.Clock import reset [as 别名]
class MovieStim2(BaseVisualStim, ContainerMixin):
"""A stimulus class for playing movies (mpeg, avi, etc...) in PsychoPy
that does not require avbin. Instead it requires the cv2 python package
for OpenCV. The VLC media player also needs to be installed on the
psychopy computer.
**Example**::
See Movie2Stim.py for demo.
"""
def __init__(self, win,
filename="",
units='pix',
size=None,
pos=(0.0,0.0),
ori=0.0,
flipVert=False,
flipHoriz=False,
color=(1.0,1.0,1.0),
colorSpace='rgb',
opacity=1.0,
volume=1.0,
name='',
loop=False,
autoLog=True,
depth=0.0,
noAudio=False,
vframe_callback=None,
fps=None
):
"""
:Parameters:
filename :
a string giving the relative or absolute path to the movie.
flipVert : True or *False*
If True then the movie will be top-bottom flipped
flipHoriz : True or *False*
If True then the movie will be right-left flipped
volume :
The nominal level is 100, and 0 is silence.
loop : bool, optional
Whether to start the movie over from the beginning if draw is
called and the movie is done.
"""
# what local vars are defined (these are the init params) for use
# by __repr__
self._initParams = dir()
self._initParams.remove('self')
super(MovieStim2, self).__init__(win, units=units, name=name,
autoLog=False)
#check for pyglet
if win.winType != 'pyglet':
logging.error('Movie stimuli can only be used with a pyglet window')
core.quit()
self._retracerate = win._monitorFrameRate
if self._retracerate is None:
self._retracerate = win.getActualFrameRate()
if self._retracerate is None:
logging.warning("FrameRate could not be supplied by psychopy; defaulting to 60.0")
self._retracerate = 60.0
self.filename = filename
self.loop = loop
self.flipVert = flipVert
self.flipHoriz = flipHoriz
self.pos = numpy.asarray(pos, float)
self.depth = depth
self.opacity = float(opacity)
self.volume = volume
self._av_stream_time_offset = 0.145
self._no_audio = noAudio
self._requested_fps = fps
self._vframe_callback = vframe_callback
self._reset()
self.loadMovie(self.filename)
self.setVolume(volume)
self.nDroppedFrames = 0
self.aspectRatio = self._video_width/float(self._video_height)
#size
if size is None:
self.size = numpy.array([self._video_width, self._video_height],
float)
elif isinstance(size, (int, float, long)):
# treat size as desired width, and calc a height
# that maintains the aspect ratio of the video.
self.size = numpy.array([size, size/self.aspectRatio], float)
else:
self.size = val2array(size)
self.ori = ori
self._updateVertices()
#set autoLog (now that params have been initialised)
self.autoLog = autoLog
if autoLog:
logging.exp("Created %s = %s" %(self.name, str(self)))
def _reset(self):
self.duration = None
self.status = NOT_STARTED
#.........这里部分代码省略.........
示例3: MovieStim2
# 需要导入模块: from psychopy.clock import Clock [as 别名]
# 或者: from psychopy.clock.Clock import reset [as 别名]
class MovieStim2(BaseVisualStim, ContainerMixin):
"""A stimulus class for playing movies (mpeg, avi, etc...) in PsychoPy
that does not require avbin. Instead it requires the cv2 python package
for OpenCV. The VLC media player also needs to be installed on the
psychopy computer.
**Example**::
See Movie2Stim.py for demo.
"""
def __init__(
self,
win,
filename="",
units="pix",
size=None,
pos=(0.0, 0.0),
ori=0.0,
flipVert=False,
flipHoriz=False,
color=(1.0, 1.0, 1.0),
colorSpace="rgb",
opacity=1.0,
volume=1.0,
name="",
loop=False,
autoLog=True,
depth=0.0,
noAudio=False,
vframe_callback=None,
fps=None,
interpolate=True,
):
"""
:Parameters:
filename :
a string giving the relative or absolute path to the movie.
flipVert : True or *False*
If True then the movie will be top-bottom flipped
flipHoriz : True or *False*
If True then the movie will be right-left flipped
volume :
The nominal level is 100, and 0 is silence.
loop : bool, optional
Whether to start the movie over from the beginning if draw is
called and the movie is done.
"""
# what local vars are defined (these are the init params) for use
# by __repr__
self._initParams = dir()
self._initParams.remove("self")
super(MovieStim2, self).__init__(win, units=units, name=name, autoLog=False)
# check for pyglet
if win.winType != "pyglet":
logging.error("Movie stimuli can only be used with a pyglet window")
core.quit()
self._retracerate = win._monitorFrameRate
if self._retracerate is None:
self._retracerate = win.getActualFrameRate()
if self._retracerate is None:
logging.warning("FrameRate could not be supplied by psychopy; defaulting to 60.0")
self._retracerate = 60.0
self.filename = filename
self.loop = loop
self.flipVert = flipVert
self.flipHoriz = flipHoriz
self.pos = numpy.asarray(pos, float)
self.depth = depth
self.opacity = float(opacity)
self.volume = volume
self._av_stream_time_offset = 0.145
self._no_audio = noAudio
self._vframe_callback = vframe_callback
self.interpolate = interpolate
self.useTexSubImage2D = True
self._texID = None
self._video_stream = cv2.VideoCapture()
self._reset()
self.loadMovie(self.filename)
self.setVolume(volume)
self.nDroppedFrames = 0
self.aspectRatio = self._video_width / float(self._video_height)
# size
if size is None:
self.size = numpy.array([self._video_width, self._video_height], float)
elif isinstance(size, (int, float, long)):
# treat size as desired width, and calc a height
# that maintains the aspect ratio of the video.
self.size = numpy.array([size, size / self.aspectRatio], float)
else:
self.size = val2array(size)
self.ori = ori
self._updateVertices()
#.........这里部分代码省略.........
示例4: MovieStim2
# 需要导入模块: from psychopy.clock import Clock [as 别名]
# 或者: from psychopy.clock.Clock import reset [as 别名]
class MovieStim2(BaseVisualStim, ContainerMixin):
"""A stimulus class for playing movies (mpeg, avi, etc...) in PsychoPy
that does not require avbin. Instead it requires the cv2 python package
for OpenCV. The VLC media player also needs to be installed on the
psychopy computer.
**Example**::
See Movie2Stim.py for demo.
"""
def __init__(self, win,
filename="",
units='pix',
size=None,
pos=(0.0,0.0),
ori=0.0,
flipVert=False,
flipHoriz=False,
color=(1.0,1.0,1.0),
colorSpace='rgb',
opacity=1.0,
volume=1.0,
name='',
loop=False,
autoLog=True,
depth=0.0,):
"""
:Parameters:
filename :
a string giving the relative or absolute path to the movie.
flipVert : True or *False*
If True then the movie will be top-bottom flipped
flipHoriz : True or *False*
If True then the movie will be right-left flipped
volume :
The nominal level is 100, and 0 is silence.
loop : bool, optional
Whether to start the movie over from the beginning if draw is
called and the movie is done.
"""
# what local vars are defined (these are the init params) for use
# by __repr__
self._initParams = dir()
self._initParams.remove('self')
super(MovieStim2, self).__init__(win, units=units, name=name,
autoLog=False)
#check for pyglet
if win.winType != 'pyglet':
logging.error('Movie stimuli can only be used with a pyglet window')
core.quit()
self._retracerate = win._monitorFrameRate
if self._retracerate is None:
self._retracerate = win.getActualFrameRate()
self.filename = filename
self.loop = loop
if loop: #and pyglet.version>='1.2':
logging.error("looping of movies is not currently supported")
self.flipVert = flipVert
self.flipHoriz = flipHoriz
self.pos = numpy.asarray(pos, float)
self.depth = depth
self.opacity = float(opacity)
self.volume = volume
self._av_stream_time_offset = 0.145
self._reset()
self.loadMovie(self.filename)
self.setVolume(volume)
self.aspectRatio = self._video_width/float(self._video_height)
#size
if size is None:
self.size = numpy.array([self._video_width, self._video_height],
float)
elif isinstance(size, (int, float, long)):
# treat size as desired width, and calc a height
# that maintains the aspect ratio of the video.
self.size = numpy.array([size, size/self.aspectRatio], float)
else:
self.size = val2array(size)
self.ori = ori
self._updateVertices()
#set autoLog (now that params have been initialised)
self.autoLog = autoLog
if autoLog:
logging.exp("Created %s = %s" %(self.name, str(self)))
def _reset(self):
self.duration = None
self.status = NOT_STARTED
self._numpy_frame = None
self._frame_texture = None
self._frame_data_interface = None
self._video_stream = None
self._total_frame_count = None
self._video_width = None
self._video_height = None
# TODO: Read depth from video source
#.........这里部分代码省略.........