stimuli.visuals.Text¶
- class stimuli.visuals.Text(window_name='Visual', window_size=None)¶
Class to display a text.
- Parameters:
Attributes
Background color in BGR color space.
Image array.
Window's center position.
Window's name.
Window's size (width x height).
Methods
close
()Close the visual.
draw_background
(color)Draw a uniform single color background.
putText
(text[, fontFace, fontScale, color, ...])Add text to the visual.
show
([wait])Show the visual with
cv2.imshow()
andcv2.waitKey()
.- close()¶
Close the visual.
- draw_background(color)¶
Draw a uniform single color background.
Replace all the pixels with this color, thus this method erases any prior work.
Notes
A color is provided as matplotlib string or as
(B, G, R)
tuple of int8 set between 0 and 255.
- putText(text, fontFace=2, fontScale=2, color='white', thickness=2, lineType=16, position='centered')¶
Add text to the visual.
- Parameters:
- text
str
Text to display.
- fontFace
int
cv2.FONT
Font to use to write the text.
- fontScale
int
Font scale factor multiplied by the font-specific base size.
- color
str
|tuple
Color used to write the text.
- thickness
int
Text line thickness in pixel.
- lineType
int
cv2.LINE
Type of line to use.
- position
str
|tuple
Position of the bottom left corner of the text. See notes for additional information.
- text
Notes
A color is provided as matplotlib string or as
(B, G, R)
tuple of int8 set between 0 and 255. The position of the object can be either defined as the string ‘center’ or ‘centered’ to position the object in the center of the window; or as a 2-length tuple of positive integer. The position is defined in pixels in opencv coordinates, with (0, 0) being the top left corner of the window.
- show(wait=1)¶
Show the visual with
cv2.imshow()
andcv2.waitKey()
.- Parameters:
- wait
int
Wait timer passed to
cv2.waitKey()
[ms].
- wait
- property background¶
Background color in BGR color space.
- property img¶
Image array.
- property window_center¶
Window’s center position.
- property window_name¶
Window’s name.
- property window_size¶
Window’s size (width x height).