""" # get the most recent video frame and extract color data colorData = movieSrc. Parameters - movieSrc : `~` Movie source object. This enables the `ImageStim` to be used as a 'viewfinder' of sorts for the camera to view a live video stream on a window. This method is used internally to copy pixel data from a camera object into a texture. def _movieFrameToTexture ( self, movieSrc ): """Convert a movie frame to a texture and use it. fset ( self, value ) # Reset the image and mask- self. setter def opacity ( self, value ): # Call setter of parent mixin BaseVisualStim. _dict_ # rebuilds the mask def opacity ( self ): # Call setter of parent mixin return BaseVisualStim. setter def contrast ( self, value ): # Call setter of parent mixin ColorMixin. _dict_ # rebuilds the mask def contrast ( self ): # Call setter of parent mixin return ColorMixin. setter def foreColor ( self, value ): # Call setter of parent mixin ColorMixin. glPopMatrix () # overload ColorMixin methods so that they refresh the image after being called def foreColor ( self ): # Call setter of parent mixin return ColorMixin. _listID ) # return the view to previous state GL. glPushMatrix () # push before the list, pop after win. ![]() _selectWindow ( win ) # If our image is a movie stim object, pull pixel data from the most # recent frame and write it to the memory if hasattr ( self. image in ( None, "None", "none" )): return # make the context for the window current if win is None : win = self. """ # check the type of image we're dealing with if ( type ( self. def draw ( self, win = None ): """Draw. clearTextures () except ( ImportError, ModuleNotFoundError, TypeError ): pass # has probably been garbage-collected already glEndList () def _del_ ( self ): """Remove textures from graphics card to prevent crash """ try : if hasattr ( self, '_listID' ): GL. GL_TEXTURE_2D ) # implicitly disables 1D # main texture GL. glVertex2f ( vertsPix, vertsPix ) # right top GL. glVertex2f ( vertsPix, vertsPix ) # left top GL. glVertex2f ( vertsPix, vertsPix ) # left bottom GL. GL_QUADS ) # draw a 4 sided polygon # right bottom GL. GL_TEXTURE_2D ) # access just once because it's slower than basic property vertsPix = self. glGetUniformLocation ( _prog, b "mask" ), 1 ) # mask GL. glGetUniformLocation ( _prog, b "texture" ), 0 ) # mask is texture unit 1 GL. glUseProgram ( _prog ) # set the texture to be texture unit 0 GL. glGetUniformLocation ( _prog, b "mask" ), 1 ) else : # for an rgb image there is no recoloring _prog = self. isLumImage : # for a luminance image do recoloring _prog = self. GL_COMPILE ) # setup the shaderprogram if self. Call it if you change a property manually rather than using the. set() Basically it updates the OpenGL representation of your stimulus if some parameter of the stimulus changes. def _updateListShaders ( self ): """ The user shouldn't need this method since it gets called after every call to. _updateList () # ie refresh display list # set autoLog now that params have been initialised wantLog = autoLog is None and self. texRes = texRes # rebuilds the mask # generate a displaylist ID self. opacity = opacity # Set the image and mask- self. colorSpace = colorSpace # omit decorator self. rgbPedestal = # does an rgb pedestal make sense for an image? self. depth = depth # color and contrast etc self. _origSize = None # updated if an image texture gets loaded self. _dict_ = mask # Not pretty (redefined later) but it works! self. _haveShaders # initialise textures for stimulus self. _init_ ( win, units = units, name = name, autoLog = False ) # set at end of init # use shaders if available by default, this is a good thing self. remove ( 'self' ) super ( ImageStim, self ). All doc is in attributes # what local vars are defined (these are the init params) for use by # _repr_ self. Class ImageStim ( BaseVisualStim, ContainerMixin, ColorMixin, TextureMixin ): """Display an image on a :class:`` """ def _init_ ( self, win, image = None, mask = None, units = "", pos = ( 0.0, 0.0 ), size = None, anchor = "center", ori = 0.0, color = ( 1.0, 1.0, 1.0 ), colorSpace = 'rgb', contrast = 1.0, opacity = None, depth = 0, interpolate = False, flipHoriz = False, flipVert = False, texRes = 128, name = None, autoLog = None, maskParams = None ): """ """ # Empty docstring.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |