This file is indexed.

/usr/share/psychtoolbox-3/PsychDemos/VideoOfflineCaptureDemo.m is in psychtoolbox-3-common 3.0.11.20140816.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
function VideoOfflineCaptureDemo(fullscreen, fullsize, roi, deviceId)
% Demonstrate use of built-in GStreamer video capture engine to capture first
% into memory, then retrieve corresponding video textures after end of capture.
%
% VideoOfflineCaptureDemo([fullscreen=0][, fullsize=0][, roi=[0 0 640 480]][,deviceId=0])
%
% VideoOfflineCaptureDemo initializes the first attached and supported camera on
% your computer (e.g, the built-in iSight of Apple Macintosh computers),
% then records video from it into memory until you press a key. It then
% fetches and displays all previously recorded images, then quits. Abort
% display by pressing any key on the keyboard.
%
% By default, the maximum supported framerate is requested and the
% timecode and interframe interval of each captured image is displayed in
% the top-left corner of the display.
%
% See also ImagingVideoCaptureDemo, VideoDelayloopMiniDemo and a few other
% nice demos.
%
% Optional parameters:
%
% 'fullscreen' If set to non-zero value, the image is displayed in a
% fullscreen window, as usual, otherwise a normal GUI window is used.
%
% 'fullsize' If set to 1, the cameras image is scaled up to full screen
% resolution, ie. so it fills the maximum amount of display area, but
% preserving the original aspect ratio.
%
% 'roi' Selects a rectangular subregion of the camera for display. By
% default, it selects a [0 0 640 480] rectangle, ie. the full are of a
% camera with 640 x 480 pixels resolution. This parameter may need tweaking
% for some cameras, as some drivers have bugs and don't work well with all
% settings.
%
% 'deviceId' Device index of video capture device. Defaults to system default.
%

% History:
% 17.04.2011  mk   Written.

AssertOpenGL;

if nargin < 1
    fullscreen=[];
end

if isempty(fullscreen)
    fullscreen=0;
end;

if nargin < 2
    fullsize=[];
end

if isempty(fullsize)
    fullsize=0;
end

if nargin < 3
    roi = [];
end

if nargin < 4 || isempty(deviceId)
    deviceId = [];
end

screenid=max(Screen('Screens'));

try
    if fullscreen<1
        win=Screen('OpenWindow', screenid, 0, [0 0 800 600]);
    else
        win=Screen('OpenWindow', screenid, 0);
    end;

    % 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);
    
    % Open framegrabber on specified capture device 'deviceId' with specified
    % resolution and region of interest 'roi'. We enforce use of capture engine
    % type '3', the GStreamer engine, as only this engine supports offline capture:
    grabber = Screen('OpenVideoCapture', win, deviceId, roi, [], [], [], [], [], 3);

    % Start videocapture at maximum framerate, do not drop frames, but keep'em all:
    [fps, t] = Screen('StartVideoCapture', grabber, realmax, 0);

    % Wait for user to stop capture:
    DrawFormattedText(win, 'Video capture active.\nPress any key to stop capture\nand start display of the results.', 'center', 'center', 255);
    Screen('Flip', win);
    KbStrokeWait;

    % Stop video capture without discarding all internally stored frames, so we can fetch'em later:
    Screen('StopVideoCapture', grabber, 0);

    % Fetch loop: Fetches and displays all captured images until keypress or all images
    % are used up:
    dstRect = [];
    oldpts = 0;
    count = 0;
    tex=0;

    while 1
        if KbCheck
            break;
        end;
        
        [tex pts nrpending] = Screen('GetCapturedImage', win, grabber, [], tex); %#ok<NASGU>
        
        if tex > 0
	    % fprintf('tex = %i  pts = %f nrpending = %i\n', tex, pts, nrpending);

            % Perform first-time setup of transformations, if needed:
            if fullsize && (count == 0)
                texrect = Screen('Rect', tex);
                winrect = Screen('Rect', win);
                sf = min([RectWidth(winrect) / RectWidth(texrect) , RectHeight(winrect) / RectHeight(texrect)]);
                dstRect = CenterRect(ScaleRect(texrect, sf, sf) , winrect);
            end

            % Draw new texture from framegrabber.
            Screen('DrawTexture', win, tex, [], dstRect);

            % Print pts as delta since start of capture:
            Screen('DrawText', win, sprintf('%.4f', pts - t), 0, 0, 255);
            if count>0
                % Compute delta:
                delta = (pts - oldpts) * 1000;
                oldpts = pts;
                % Display delta between successive frames in msecs:
                Screen('DrawText', win, sprintf('%.4f', delta), 0, 20, 255);
            end;
            
            % Show it.
            Screen('Flip', win);
	else
            % Done with fetching.
	    break;
        end;

        count = count + 1;
    end;

    % Close capture device: This will release all not yet fetched images:
    Screen('CloseVideoCapture', grabber);

    % Close window, clean up.
    Screen('CloseAll');
catch
    Screen('CloseAll');
end;