vid1
Query for hardware information
gh = imaqhwinfo(); disp(gh);
InstalledAdaptors: {'coreco' 'winvideo'} MATLABVersion: '7.10 (R2010a)' ToolboxName: [1x25 char] ToolboxVersion: '3.5 (R2010a)'
Query individual instruments
gh = imaqhwinfo('winvideo'); n = length(gh.DeviceInfo); for k=1:n gi = gh.DeviceInfo(k); disp(gi); str = char(gi.ObjectConstructor); fprintf('\nObjectConstructor: %s\n',str); vid = eval(str); fprintf('\nSupported Formats\n'); disp(gi.SupportedFormats'); delete(vid); end
DefaultFormat: 'YUY2_160x120' DeviceFileSupported: 0 DeviceName: 'USB Video Device' DeviceID: 1 ObjectConstructor: [1x25 char] SupportedFormats: {1x5 cell} ObjectConstructor: videoinput('winvideo', 1) Supported Formats 'YUY2_160x120' 'YUY2_176x144' 'YUY2_320x240' 'YUY2_352x288' 'YUY2_640x480'
vid = videoinput('winvideo',1,'YUY2_640x480'); preview(vid) pause(1)
disp(vid) info = get(vid); disp(info)
Summary of Video Input Object Using 'USB Video Device'. Acquisition Source(s): input1 is available. Acquisition Parameters: 'input1' is the current selected source. 10 frames per trigger using the selected source. 'YUY2_640x480' video data to be logged upon START. Grabbing first of every 1 frame(s). Log data to 'memory' on trigger. Trigger Parameters: 1 'immediate' trigger(s) on START. Status: Waiting for START. 0 frames acquired since starting. 0 frames available for GETDATA. BayerSensorAlignment: 'grbg' DeviceID: 1 DiskLogger: [] DiskLoggerFrameCount: 0 ErrorFcn: @imaqcallback EventLog: [1x0 struct] FrameGrabInterval: 1 FramesAcquired: 0 FramesAcquiredFcn: [] FramesAcquiredFcnCount: 0 FramesAvailable: 0 FramesPerTrigger: 10 InitialTriggerTime: [] Logging: 'off' LoggingMode: 'memory' Name: [1x23 char] NumberOfBands: 3 Previewing: 'on' ReturnedColorSpace: 'YCbCr' ROIPosition: [0 0 640 480] Running: 'off' SelectedSourceName: 'input1' Source: [1x1 videosource] StartFcn: [] StopFcn: [] Tag: '' Timeout: 10 TimerFcn: [] TimerPeriod: 1 TriggerCondition: 'none' TriggerFcn: [] TriggerFrameDelay: 0 TriggerRepeat: 0 TriggersExecuted: 0 TriggerSource: 'none' TriggerType: 'immediate' Type: 'videoinput' UserData: [] VideoFormat: 'YUY2_640x480' VideoResolution: [640 480]
src = getselectedsource(vid); disp(src) info = get(src); disp(info)
Display Summary for Video Source Object: Index: SourceName: Selected: 1 'input1' 'on' BacklightCompensation: 'on' Brightness: 30 Contrast: 57 FrameRate: '30.0000' Gamma: 3 Parent: [1x1 videoinput] Saturation: 2 Selected: 'on' Sharpness: 10 SourceName: 'input1' Tag: '' Type: 'videosource'
set(vid,'ReturnedColorSpace','rgb'); img = getsnapshot(vid); % rgb = ycbcr2rgb(img); % don't need to convert colorspace earlier imshow(img); closepreview(vid)
start(vid); data = getdata(vid); imaqmontage(data);
delete(vid);
clear all;