forked from DIDSR/eeDAP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera_open.m
More file actions
70 lines (61 loc) · 2.5 KB
/
camera_open.m
File metadata and controls
70 lines (61 loc) · 2.5 KB
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
function cam=camera_open(cam_kind,cam_format)
try
% imaqtool: launches an interactive GUI to allow you to explore,
% configure, and acquire data from your installed and supported image
% acquisition devices
% imaqhwinfo: a structure that contains information about the image
% acquisition adaptors available on the system. An adaptor is the
% interface between MATLAB® and the image acquisition devices
% connected to the system. The adaptor's main purpose is to pass
% information between MATLAB and an image acquisition device via its
% driver.
% imaqhwinfo(adaptorname): returns out, a structure that contains
% information about the adaptor specified by the text string
% adaptorname. The information returned includes adaptor version and
% available hardware for the specified adaptor.
% imaqfind: matlab function to find image acquisition objects
% http://www.mathworks.com/help/imaq/configuring-image-acquisition-object-properties.html
% delete any currently running (stale) video inputs
objects = imaqfind;
delete(objects);
if strcmp( cam_kind,'USB')
cam_adaptor = 'pointgrey';
elseif strcmp( cam_kind,'Firewire')
cam_adaptor = 'dcam';
end
% Create the video object to communicate with the camera
if exist('cam_format','var')
cam = videoinput(cam_adaptor,1,cam_format) %#ok<NOPRT>
else
cam = videoinput(cam_adaptor,1) %#ok<NOPRT>
end
imaqhwinfo(cam)
cam.Tag = 'Microscope Camera Object';
cam.TriggerRepeat = 0;
cam.FramesPerTrigger = 10;
cam.FrameGrabInterval = 1;
dim = cam.VideoResolution;
% Camera iamge must be at least 640 x 480
if dim(1) < 640 || dim(2) < 480
desc = 'Camera image must be at least 640x480' %#ok<NOPRT>
h_errordlg = errordlg(desc,'Insufficient Camera Size','modal');
uiwait(h_errordlg)
close all force
end
% Camera image must be rgb
if ~strcmp(cam.ReturnedColorSpace,'rgb');
desc = 'Camera image must be rgb' %#ok<NOPRT>
h_errordlg = errordlg(desc,'Insufficient Camera Size','modal');
uiwait(h_errordlg)
close all force
end
% Set value of a video source object property.
cam_src = getselectedsource(cam);
cam_src.Tag = 'Microscope Camera Source';
if strcmp( cam_kind,'USB')
cam_src.WhiteBalanceRBMode = 'Off';
end
catch ME
error_show(ME)
end
end