I am hoping to present 3 videos and webcam footage on one screen in my PsychoPy experiment. I have added the 3 video stimuli to the screen and have used the code below to turn on the webcam on my laptop and get it to take a still picture, which it presents to me after the experiment.
Does anyone have any suggestions for how to add code that will present the webcam footage (as a video or as several still frames) on the screen as it’s recording it? Thank you for any help.
Code:
from psychopy import visual, event, core
from PIL import Image
import time, pylab, cv2, numpy
myWin = visual.Window(allowGUI=False, monitor=‘testMonitor’, units=‘norm’,colorSpace=‘rgb’,color=[-1,-1,-1], fullscr=True)
myWin.setMouseVisible(True)
cam = cv2.VideoCapture(0)
cam.open(0, cv2.CAP_DSHOW)
status, frame = cam.read()
cv2.imshow(‘camera1’, frame)
visual.ImageStim(myWin, image=frame)
webcam = Image.fromarray(frame, ‘RGB’)
webcam.show()