I want to display an image RGB image. but the image is not a string of the image directory. it a numpy array with size 256x256x3. I have tried with both ImageStim and GratingStim but it did not work. it just displays the background without the image. I am using the psychopy version ‘2020.1.2’.
I have tried many things: scaled the image between -1 and 1; scaled the image between 0 and 1; scaled between 0 and 255; I have converted the image with a size 3x256x256. All of them gave me the same results. it only shows the background.
import numpy as np
import cv2 as cv
from psychopy import visual as pp_visual
win = pp_visual.Window(
color=[0, 0, 0],
colorSpace='rgb',
units="pix",
fullscr=False,
allowGUI=False)
directory_t_pose = 'T_pose.png'
image_t_pose = (cv.imread(directory_t_pose).astype(float) / 255 * 2) - 1
frame_t_pose = pp_visual.ImageStim(win=win, image=image_t_pose)
for t in range(100):
frame_t_pose.draw()
win.flip()