/usr/share/psychtoolbox-3/PsychAlpha/BlurredVideoCaptureDemo.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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | function BlurredVideoCaptureDemo(filtertype, kwidth)
AssertOpenGL;
screen=max(Screen('Screens'));
if nargin < 1
filtertype = 1;
end
if nargin < 2
kwidth=11;
end;
try
InitializeMatlabOpenGL;
win=Screen('OpenWindow', screen, 0);
% Initial flip to a blank screen:
Screen('Flip',win);
% Set text size for info text. 24 pixels is also good for Linux.
Screen('TextSize', win, 24);
% Build a filter kernel:
stddev = kwidth / 3;
switch(filtertype)
case 0
kernel = [];
case 1
kernel = fspecial('gaussian', kwidth, stddev);
case 2
kernel = fspecial('prewitt');
case 3
kernel = fspecial('unsharp');
case 4
kernel = fspecial('sobel');
case 5
kernel = fspecial('log');
end
if filtertype > 0
% Build shader from kernel:
shader = EXPCreateStatic2DConvolutionShader(kernel, 3, 3, 0, 1);
else
% No filtering requested: Select fixed-function pipeline
shader = 0;
end
grabber = Screen('OpenVideoCapture', win, 0, [0 0 640 480]);
brightness = Screen('SetVideoCaptureParameter', grabber, 'Brightness',383)
exposure = Screen('SetVideoCaptureParameter', grabber, 'Exposure',130)
gain = Screen('SetVideoCaptureParameter', grabber, 'Gain')
gamma = Screen('SetVideoCaptureParameter', grabber, 'Gamma')
shutter = Screen('SetVideoCaptureParameter', grabber, 'Shutter',7)
Screen('SetVideoCaptureParameter', grabber, 'PrintParameters')
vendor = Screen('SetVideoCaptureParameter', grabber, 'GetVendorname')
model = Screen('SetVideoCaptureParameter', grabber, 'GetModelname')
% Setup mirror transformation for horizontal flipping:
% xc, yc is the geometric center of the text.
[xc, yc] = RectCenter(Screen('Rect', win));
% Translate origin into the geometric center of text:
Screen('glTranslate', win, xc, 0, 0);
% Apple a scaling transform which flips the direction of x-Axis,
% thereby mirroring the drawn text horizontally:
Screen('glScale', win, -1, 1, 1);
% We need to undo the translations...
Screen('glTranslate', win, -xc, 0, 0);
% The transformation is ready for mirrored drawing:
Screen('StartVideoCapture', grabber, 60, 1);
oldpts = 0;
count = 0;
t=GetSecs;
while (GetSecs - t) < 600
if KbCheck
break;
end;
[tex pts nrdropped]=Screen('GetCapturedImage', win, grabber, 1);
% fprintf('tex = %i pts = %f nrdropped = %i\n', tex, pts, nrdropped);
if (tex>0)
% Draw new texture from framegrabber.
Screen('DrawTexture', win, tex, [], [], [], [], [], [], shader);
% Print pts:
% Screen('DrawText', win, sprintf('%.4f', pts - t), 0, 0, 255);
if count>0
% Compute delta:
delta = (pts - oldpts) * 1000;
oldpts = pts;
% Screen('DrawText', win, sprintf('%.4f', delta), 0, 20, 255);
end;
% Show it.
Screen('Flip', win);
Screen('Close', tex);
tex=0;
end;
count = count + 1;
end;
telapsed = GetSecs - t
Screen('StopVideoCapture', grabber);
Screen('CloseVideoCapture', grabber);
Screen('CloseAll');
avgfps = count / telapsed
catch
Screen('CloseAll');
end;
|