stimuli.visuals.Cross

class stimuli.visuals.Cross(window_name='Visual', window_size=None)

Class to display a cross, e.g. a fixation cross.

Parameters:
window_namestr

Name of the window in which the visual is displayed.

window_sizetuple | None

Either None to automatically select a window size based on the available monitors, or a 2-length of positive integer sequence as (width, height) in pixels.

Attributes

background

Background color in BGR color space.

img

Image array.

window_center

Window's center position.

window_name

Window's name.

window_size

Window's size (width x height).

Methods

close()

Close the visual.

draw_background(color)

Draw a uniform single color background.

putCross(length, thickness, color[, position])

Draw a cross composed of 2 rectangles.

show([wait])

Show the visual with cv2.imshow() and cv2.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.

Parameters:
colorstr | tuple

Color used to draw the background.

Notes

A color is provided as matplotlib string or as (B, G, R) tuple of int8 set between 0 and 255.

putCross(length, thickness, color, position='centered')

Draw a cross composed of 2 rectangles.

The rectangles are defined by length and thickness. The rectangles are positioned to form a cross.

Parameters:
lengthint

Number of pixels used to draw the length of the cross.

thicknessint

Number of pixels used to draw the thickness of the cross.

colorstr | tuple

Color used to fill the cross.

positionstr | tuple

Position of the center of the cross. See notes for additional information.

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() and cv2.waitKey().

Parameters:
waitint

Wait timer passed to cv2.waitKey() [ms].

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).