1、  查询USB2.0Camera 的具体参数
输入 imaqInfo = imaqhwinfo
  返回信息
         InstalledAdaptors: {'winvideo'}
        MATLABVersion: '7.1 (R14SP3)'
          ToolboxName: 'Image Acquisition Toolbox'
       ToolboxVersion: '1.9 (R14SP3)'
输入imaqInfo.InstalledAdaptors
   返回信息
       ans =
 
'winvideo'
   输入winvideoinfo = imaqhwinfo('winvideo')
      返回信息
       winvideoinfo =
 
       AdaptorDllName: [1x76 char]
    AdaptorDllVersion: '1.9 (R14SP3)'
          AdaptorName: 'winvideo'
            DeviceIDs: {[1]}
           DeviceInfo: [1x1 struct]
输入 winvideoinfo.DeviceInfo
    返回信息
       
ans =
 
          DefaultFormat: 'YUY2_160x120'
    DeviceFileSupported: 0
             DeviceName: 'USB 视频设备'
               DeviceID: 1
      ObjectConstructor: 'videoinput('winvideo', 1)'
       SupportedFormats: {1x5 cell}
输入device1 = winvideoinfo.DeviceInfo(1)
    返回信息
       
device1 =
 
          DefaultFormat: 'YUY2_160x120'
    DeviceFileSupported: 0
             DeviceName: 'USB 视频设备'
               DeviceID: 1
      ObjectConstructor: 'videoinput('winvideo', 1)'
       SupportedFormats: {1x5 cell}
输入device1.DeviceName
    返回信息
        ans =
 
USB 视频设备
输入device1.DeviceID
    返回信息
       
ans =
 
     1
输入device1.DefaultFormat
    返回信息
        ans =
 
YUY2_160x120
输入device1.SupportedFormats
    返回信息
    Columns 1 through 4
 
    'YUY2_160x120'    'YUY2_176x144'    'YUY2_320x240'    'YUY2_352x288'
 
    Column 5
 
    'YUY2_640x480'
2、  最简单采集实验,输入如下代码,可以得到预览下的默认格式的摄像头捕捉窗口
obj=videoinput('winvideo',1);
preview(obj);
3、  输入如下代码
    % Access an p_w_picpath acquisition device.
vidobj = videoinput('winvideo',1,'YUY2_640x480');
sources = vidobj.Source;
whos sources
 
set(vidobj,'SelectedSourceName','input1');
sources
selectedsrc = getselectedsource(vidobj);
get(selectedsrc);
delete(vidobj);
clear vidobj;
 
返回信息
    Name          Size                    Bytes  Class
 
  sources       1x1                       726  videosource object
 
Grand total is 30 elements using 726 bytes
 
 
   Display Summary for Video Source Object:
 
      Index:   SourceName:   Selected:
            'input1'      'on'    
 
  General Settings:
    Parent = [1x1 videoinput]
    Selected = on
    SourceName = input1
    Tag =
    Type = videosource
 
  Device Specific Properties:
    BacklightCompensation = on
    Brightness = -16
    Contrast = 120
    FrameRate = 30.0000
    Gamma = 60
    Hue = 0
    Saturation = 40
Sharpness = 3
 
4、  输入如下代码
clc;
clf;
clear all;
imaqmem(30000000);               %申请内存空间
%ADAPTOR:MATLAB与视频设备之间的接口,主要的目的是传递信息
 
vid = videoinput('winvideo', 1, 'YUY2_640x480');
preview(vid);
start(vid);
h=figure('NumberTitle','off','Name','视频',...
    'MenuBar','none','color','c',...
    'Position', [0, 0, 1, 1], 'Visible', 'on');         %新建窗口
set(h,'doublebuffer','on','outerposition',get(0,'screensize'));
h1=axes('Position', [0.02, 0.1, 0.4, 0.8],'Parent',h); %新建显示窗口
hold on;
axis off;
while ishandle(h)     %判断是否有效的图像对象句柄
    a=getsnapshot (vid);     % 捕获图像
    flushdata(vid);     %清除数据获取引擎的所有数据、置属性SamplesAvailable为0
    imshow(a);                   %显示图像
    drawnow;                     % 实时更新图像
end;
delete(vid);