/usr/share/psychtoolbox-3/PsychDemos/KinectDemo.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 | function KinectDemo
% KinectDemo - Capture and display video and depths data from a Kinect box.
%
% This connects to a Microsoft Kinect device on the USB bus, then captures
% and displays video and depths data delivered by the Kinect.
%
% Press any key to quit the demo.
%
% See help PsychKinect, help PsychKinectCore and help InstallKinect for
% further info.
%
% History:
% 25.11.2010 mk Written.
AssertOpenGL
%PsychDebugWindowConfiguration;
InitializeMatlabOpenGL([],[],1);
GetSecs;
dst1 = [0, 0, 640, 480];
dst2 = [650, 0, 650+640, 480];
w = Screen('Openwindow', 0, 0, [0 0 1300 500], [], [], [], [], [], kPsychGUIWindow);
kinect = PsychKinect('Open');
PsychKinect('Start', kinect);
count = 0;
ts = GetSecs;
while 1
[rc, cts] = PsychKinect('GrabFrame', kinect, 1);
if rc > 0
count = count + 1;
%fprintf('Kinect frame %i, cts = %f\n', count, cts);
[imbuff, width, height, channels] = PsychKinect('GetImage', kinect, 0, 1);
if width > 0 && height > 0
tex = Screen('SetOpenGLTextureFromMemPointer', w, [], imbuff, width, height, channels, 1, GL.TEXTURE_RECTANGLE_EXT);
Screen('DrawTexture', w, tex, [], dst1);
Screen('Close', tex);
end
[imbuff, width, height, channels] = PsychKinect('GetImage', kinect, 1, 1);
if width > 0 && height > 0
tex = Screen('SetOpenGLTextureFromMemPointer', w, [], imbuff, width, height, channels, 1, GL.TEXTURE_RECTANGLE_EXT);
Screen('DrawTexture', w, tex, [], dst2);
Screen('Close', tex);
end
if 0
[imbuff, width, height, channels] = PsychKinect('GetDepthImage', kinect, 2, 0);
if 0
imagesc(imbuff);
drawnow;
minz = min(min(imbuff))
maxz = max(max(imbuff))
else
scatter3(imbuff(1,:,:), imbuff(2,:,:), imbuff(3,:,:));
drawnow;
end
end
PsychKinect('ReleaseFrame', kinect);
Screen('Flip', w);
else
WaitSecs('YieldSecs', 0.005);
end
[x,y,buttons]=GetMouse;
if (x == 0 && y == 0)
GetClicks;
end
if KbCheck(-1)
break;
end
end
fprintf('Average fps = %f [%i]\n', count / (GetSecs - ts), count);
PsychKinect('Stop', kinect);
PsychKinect('Close', kinect);
sca;
|