A Simple "Hello World" In Stereo
In this demo, we use PsychoPy to generate a stereoscopic display. The word “Hello” is presented to one eye, and the word “World” is presented to the other. The demo uses frame-sequential stereo and Stereo Blue Lines to assign each frame to the left and right eye.
This demo uses the 3DPixx active shutter glasses and the VIEWPixx /3D. The code can easily be modified for a PROPixx and 3D Polarizer.
If you are new to 3D stimulus presentation using the PROPixx or VIEWPixx /3D, we recommend reading the following introductory guides:
from psychopy import core, visual
from psychopy.hardware import keyboard
from pypixxlib.viewpixx import VIEWPixx3D
from pypixxlib._libdpx import DPxEnableVidLcd3D60Hz, DPxSetVidVesaPhase, DPxIsVidVesaBlueline
def initializeVPx3D():
#All VPixx hardware commands to set the right mode for the VIEWPixx 3D
my_device = VIEWPixx3D()
my_device.setVideoMode('C24')
my_device.setVideoVesaBlueline(True)
my_device.setVesaWaveform('NVIDIA') #or VOLFONI
DPxSetVidVesaPhase(100)
DPxEnableVidLcd3D60Hz()
my_device.updateRegisterCache()
return my_device
def drawBlueLine(win, frame=0):
#Helper function to draw lines on the appropriate image
#if Frame = 0, draw left eye blueline
#if Frame = 1 draw right eye no blueline
#Call immediately before flip
if frame==0:
frameColor = [0,0,255]
else:
frameColor = [0,0,0]
rowStart= [-win.size[0]/2, win.size[1]/2]
rowEnd =[win.size[0]/2, win.size[1]/2]
line = visual.Line(
win=win,
units = 'pix',
start=rowStart,
end=rowEnd,
interpolate = False, #MUST be set to false
colorSpace = 'rgb255',
lineColor = frameColor)
line.draw()
#Begin Experiment
kb = keyboard.Keyboard()
VPx = initializeVPx3D()
win = visual.Window(
screen = 1,
monitor =None,
fullscr=True,
color='black',
units = "pix"
)
#Initialize our stimuli
hello = visual.TextStim(win=win, text='Hello')
world = visual.TextStim(win=win, text='World')
#Start a loop drawing our message
while True:
hello.draw()
drawBlueLine(win, frame=0)
win.flip()
world.draw()
drawBlueLine(win, frame=1)
win.flip()
keys = kb.getKeys(keyList=['escape'])
if keys:
break
win.close()
core.quit()