forked from petercorke/machinevision-toolbox-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoCamera.m
47 lines (43 loc) · 1.61 KB
/
VideoCamera.m
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
%VideoCamera Abstract class to read from local video camera
%
% A concrete subclass of ImageSource that acquires images from a local
% camera using the MATLAB Image Acquisition Toolbox (imaq). This Toolbox
% provides a multiplatform interface to a range of cameras, and this
% class provides a simple wrapper.
%
% This class is not intended to be used directly, instead use the factory
% method Video which will return an instance of this class if the Image
% Acquisition Toolbox is installed, for example
%
% vid = VideoCamera();
%
% Methods::
% grab Aquire and return the next image
% size Size of image
% close Close the image source
% char Convert the object parameters to human readable string
%
% See also VideoCamera, ImageSource, AxisWebCamera, Movie.
function vid = VideoCamera(varargin)
opt.simple = false;
[opt,args] = tb_optparse(opt, varargin);
% this function looks like a class, the only way to implement the
% factory design pattern
if exist('imaqhwinfo', 'file') && ~opt.simple
% we have the Mathworks Image Acquisition Toolbox
if length(args) == 1 && strcmp(args{1}, '?')
VideoCamera_IAT.list();
else
vid = VideoCamera_IAT(args{:});
end
elseif exist('framegrabber', 'file') == 3
% we have the MVTB framegrabber MEX interface, for either
% MacOS, Linux or Windows
if length(args) == 1 && strcmp(args{1}, '?')
VideoCamera_fg.list();
else
vid = VideoCamera_fg(args{:});
end
else
error('no video capture capability on this computer');
end