test.m
来自「1394 接口视觉工具箱 (英文工具箱」· M 代码 · 共 109 行
M
109 行
% test program to continiously capture stereoscopic pictures from the
% first 2 cameras on the bus
%
% try..
% >> test
%
% ... or
%
% >> test(2, 100, 100, 50, 200)
function test(varargin)
supportedModes = { ...
'YUV444 (160x120, 30 fps)', ...
'YUV422 (320x240, 30 fps)', ...
'YUV411 (640x480, 30 fps)', ...
'YUV422 (640x480, 15 fps)', ...
'RGB8 (640x480, 15 fps)', ...
'Y8 (640x480, 30 fps)', ...
'Y16 (640x480, 15 fps)' ...
};
if(isempty(varargin))
disp('Image type not specified - using YUV as the default');
mode = 2; % default mode: YUV411 (640x320, 30 fps)
myWidth = -1; % default width (max)
myHeight = -1; % default height (max)
myOrigX = -1; % default origin-x (0)
myOrigY = -1; % default origin-y (0)
elseif(nargin == 1 && isnumeric(varargin{1}))
mode = varargin{1};
myWidth = -1; % default width (max)
myHeight = -1; % default height (max)
myOrigX = -1; % default origin-x (0)
myOrigY = -1; % default origin-y (0)
elseif(nargin == 3 && isnumeric(varargin{1}) && isnumeric(varargin{2}) && isnumeric(varargin{3}))
mode = varargin{1};
myWidth = varargin{2};
myHeight = varargin{3};
myOrigX = -1; % default origin-x (0)
myOrigY = -1; % default origin-y (0)
elseif(nargin == 5 && isnumeric(varargin{1}) && isnumeric(varargin{2}) && isnumeric(varargin{3}) ...
&& isnumeric(varargin{4}) && isnumeric(varargin{5}))
mode = varargin{1};
myWidth = varargin{2};
myHeight = varargin{3};
myOrigX = varargin{4};
myOrigY = varargin{5};
end
if(mode == -1)
% switch camera off
capImageStereo(-1);
else
% ensure we can exit from the while(1) loop gracefully...
steroOut = figure;
set(gcf, 'Position', [20 100 950 400]);
set(gcf, 'MenuBar', 'none');
set(gcf, 'Name', 'Stereoscopic Vision');
subplot(1,2,1)
title('first camera')
axis image
subplot(1,2,2)
title('second camera')
axis image
evalin('base', 'run = 1;');
set(steroOut, 'CloseRequestFcn', 'evalin(''base'', ''run = 0;'');');
run = 1;
while(run)
try
% verbosity: on (2nd call-up parameter)
[im1, im2] = capImageStereo(mode, 1, myWidth, myHeight, myOrigX, myOrigY);
subplot(1,2,1)
image(im1);
title('camera #1 -- Close figure window to exit (e.g. ALT+F4)')
axis image
drawnow
subplot(1,2,2)
image(im2);
title('camera #2 -- Close figure window to exit (e.g. ALT+F4)')
axis image
drawnow
catch
% catch driver errors (e.g. unsupported modes)
set(gcf, 'CloseRequestFcn', 'closereq');
close all
rethrow(lasterror)
end
% fetch 'run' from 'base' WS
run = evalin('base', 'run');
end
end
% switch camera off...
capImageStereo(-1);
set(steroOut, 'CloseRequestFcn', 'closereq');
close all
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?