Hi all, hope you good people can help me figure out if the behavior of
BufferImageStim reflects a bug, or if I am doing it wrong.
Long story short, I am developing a somewhat visually complex and interactive experiment, and want to give participants visual feedback so they can compare their solution with the correct one. So, I thought a good approach would be taking a “screenshot” of their finished product using
BufferImageStim and then displaying this side by side with the correct one.
But, I’m having a hard time figuring out how to use the
rect argument to “screenshot” a specific region. The documentation here says the
rect argument should be “a list of edges [left, top, right, bottom] defining a screen rectangle which is the area to capture from the screen, given in norm units”. Unfortunately, this seems to be wrong, or I don’t understand the description.
Consider the example below. I would expect setting
rect= [-1, 1, 1, 0] to capture the top half of the window, but it appears that the opposite is happening, and it’s capturing the bottom half?
from psychopy import visual, event win = visual.Window() im = visual.ImageStim(win, image="face.jpg") # face.jpg is attached, it's the same one that comes with the coder demos instructions = visual.TextStim(win, pos=(0, -.75), text="Press any key to screenshot upper half of window") border = visual.Line(win, start=(-1, 0), end=(1, 0)) # Horizontal midline to divide top and bottom half border.draw() im.draw() instructions.draw() win.flip() event.waitKeys() shot = visual.BufferImageStim(win, stim=[im], rect=[-1, 1, 1, 0]) instructions.text = "Press any key to close the window" win.color = (-1, 0, 0) # change background so screenshot region is distinguishable win.flip() border.draw() shot.draw() instructions.draw() win.flip() event.waitKeys()
Any help understanding this is appreciated! Here is the link to face.jpg, it’s the same file that comes with the coder demos.