/usr/share/psychtoolbox-3/PsychDemos/StereoViewer.m is in psychtoolbox-3-common 3.0.9+svn2579.dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | function StereoViewer(leftimfile, rightimfile, stereoMode, imaging)
% StereoViewer(leftimfile, rightimfile [,stereoMode=8] [,imaging=0])
%
% Minimalistic viewer for stereo image pairs. Reads image for left-eye from
% file 'leftimfile', reads right-eye image from file 'rightimfile'.
% 'stereoMode' mode of presentation, defaults to mode 8 (Red-Blue
% Anaglyph). 'imaging' if set to 1, will use the Psychtoolbox imaging
% pipeline for stereo display -- allows to set gains for anaglyph stereo.
%
% The viewer just shows the image pair. The left image is centered on the
% screen, the right images position can be moved by moving the mouse cursor
% to align for inter-eye distance. Press any key to quit the viewer.
% History:
% 14.05.2007 Written (MK)
AssertOpenGL;
if nargin < 2
error('You must at least provide names of image files for stereo pair.');
end
if nargin < 3
stereoMode = [];
end
if isempty(stereoMode)
stereoMode = 8;
end
if nargin < 4
imaging = 0;
end
if imaging > 0
imaging = kPsychNeedFastBackingStore;
end
screenid = max(Screen('Screens'));
[win, winRect] = Screen('OpenWindow', screenid, 0, [], [], [], stereoMode, [], imaging);
if imaging
% Set color gains. This depends on the anaglyph mode selected:
switch stereoMode
case 6,
SetAnaglyphStereoParameters('LeftGains', win, [1.0 0.0 0.0]);
SetAnaglyphStereoParameters('RightGains', win, [0.0 0.6 0.0]);
case 7,
SetAnaglyphStereoParameters('LeftGains', win, [0.0 0.6 0.0]);
SetAnaglyphStereoParameters('RightGains', win, [1.0 0.0 0.0]);
case 8,
SetAnaglyphStereoParameters('LeftGains', win, [0.4 0.0 0.0]);
SetAnaglyphStereoParameters('RightGains', win, [0.0 0.2 0.7]);
case 9,
SetAnaglyphStereoParameters('LeftGains', win, [0.0 0.2 0.7]);
SetAnaglyphStereoParameters('RightGains', win, [0.4 0.0 0.0]);
otherwise
%error('Unknown stereoMode specified.');
end
end
imgl=Screen('MakeTexture', win, imread(leftimfile));
imgr=Screen('MakeTexture', win, imread(rightimfile));
imgrect = Screen('Rect', imgr);
% Position mouse on center of display:
[x , y] = RectCenter(winRect);
SetMouse(x, y, win);
% Hide mouse cursor:
HideCursor;
while ~KbCheck
% Query mouse position:
[x,yd] = GetMouse(win);
Screen('SelectStereoDrawBuffer', win, 0);
Screen('DrawTexture', win, imgl);
Screen('SelectStereoDrawBuffer', win, 1);
% Draw right image centered on mouse position -- mouse controls image
% offsets:
Screen('DrawTexture', win, imgr, [], CenterRectOnPoint(imgrect, x, y));
Screen('Flip', win);
end
% Show mouse cursor:
ShowCursor;
Screen('CloseAll');
return;
|