vid1

Query for hardware information

gh = imaqhwinfo();
disp(gh);
    InstalledAdaptors: {'winvideo'}
        MATLABVersion: '8.5 (R2015a)'
          ToolboxName: 'Image Acquisition Toolbox'
       ToolboxVersion: '4.9 (R2015a)'

Query individual instruments

gh = imaqhwinfo('winvideo');
n = length(gh.DeviceInfo);
for k=1:n
    gi = gh.DeviceInfo(k);
    disp(gi);
    fprintf('\nSupported Formats\n');
    disp(gi.SupportedFormats');
end
             DefaultFormat: 'MJPG_1280x720'
       DeviceFileSupported: 0
                DeviceName: 'HP HD Webcam [Fixed]'
                  DeviceID: 1
     VideoInputConstructor: 'videoinput('winvideo', 1)'
    VideoDeviceConstructor: 'imaq.VideoDevice('winvideo', 1)'
          SupportedFormats: {1x12 cell}


Supported Formats
    'MJPG_1280x720'
    'MJPG_176x144'
    'MJPG_320x240'
    'MJPG_352x288'
    'MJPG_640x400'
    'MJPG_640x480'
    'YUY2_1280x720'
    'YUY2_176x144'
    'YUY2_320x240'
    'YUY2_352x288'
    'YUY2_640x400'
    'YUY2_640x480'

Information on a specific device can be obtained by simply indexing into the device information structure array.

device1 = gh.DeviceInfo(1)
device1 = 

             DefaultFormat: 'MJPG_1280x720'
       DeviceFileSupported: 0
                DeviceName: 'HP HD Webcam [Fixed]'
                  DeviceID: 1
     VideoInputConstructor: 'videoinput('winvideo', 1)'
    VideoDeviceConstructor: 'imaq.VideoDevice('winvideo', 1)'
          SupportedFormats: {1x12 cell}

vid = videoinput('winvideo',1);
preview(vid)
pause(1)
closepreview;
disp(vid)
Summary of Video Input Object Using 'HP HD Webcam [Fixed]'.

   Acquisition Source(s):  input1 is available.

  Acquisition Parameters:  'input1' is the current selected source.
                           10 frames per trigger using the selected source.
                           'MJPG_1280x720' 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.

get(vid)
  General Settings:
    DeviceID = 1
    DiskLogger = []
    DiskLoggerFrameCount = 0
    EventLog = [1x0 struct]
    FrameGrabInterval = 1
    FramesAcquired = 0
    FramesAvailable = 0
    FramesPerTrigger = 10
    Logging = off
    LoggingMode = memory
    Name = MJPG_1280x720-winvideo-1
    NumberOfBands = 3
    Previewing = off
    ROIPosition = [0 0 1280 720]
    Running = off
    Tag = 
    Timeout = 10
    Type = videoinput
    UserData = []
    VideoFormat = MJPG_1280x720
    VideoResolution = [1280 720]

  Color Space Settings:
    BayerSensorAlignment = grbg
    ReturnedColorSpace = rgb

  Callback Function Settings:
    ErrorFcn = @imaqcallback
    FramesAcquiredFcn = []
    FramesAcquiredFcnCount = 0
    StartFcn = []
    StopFcn = []
    TimerFcn = []
    TimerPeriod = 1
    TriggerFcn = []

  Trigger Settings:
    InitialTriggerTime = []
    TriggerCondition = none
    TriggerFrameDelay = 0
    TriggerRepeat = 0
    TriggersExecuted = 0
    TriggerSource = none
    TriggerType = immediate

  Acquisition Sources:
    SelectedSourceName = input1
    Source = [1x1 videosource]

info = get(vid);
disp(info)
      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: 'MJPG_1280x720-winvideo-1'
             NumberOfBands: 3
                Previewing: 'off'
        ReturnedColorSpace: 'rgb'
               ROIPosition: [0 0 1280 720]
                   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: 'MJPG_1280x720'
           VideoResolution: [1280 720]

src = getselectedsource(vid);
disp(src)
   Display Summary for Video Source Object:

      General Settings:
        Parent = [1x1 videoinput]
        Selected = on
        SourceName = input1
        Tag = [0x0 string]
        Type = videosource

      Device Specific Properties:
        BacklightCompensation = on
        Brightness = 0
        Contrast = 32
        Exposure = -6
        ExposureMode = auto
        FrameRate = 30.0000
        Gamma = 100
        Hue = 0
        Saturation = 64
        Sharpness = 3
        WhiteBalance = 4600
        WhiteBalanceMode = auto

get(src)
      General Settings:
        Parent = [1x1 videoinput]
        Selected = on
        SourceName = input1
        Tag = [0x0 string]
        Type = videosource

      Device Specific Properties:
        BacklightCompensation = on
        Brightness = 0
        Contrast = 32
        Exposure = -6
        ExposureMode = auto
        FrameRate = 30.0000
        Gamma = 100
        Hue = 0
        Saturation = 64
        Sharpness = 3
        WhiteBalance = 4600
        WhiteBalanceMode = auto

info = get(src);
disp(info)
    BacklightCompensation: 'on'
               Brightness: 0
                 Contrast: 32
                 Exposure: -6
             ExposureMode: 'auto'
                FrameRate: '30.0000'
                    Gamma: 100
                      Hue: 0
                   Parent: [1x1 videoinput]
               Saturation: 64
                 Selected: 'on'
                Sharpness: 3
               SourceName: 'input1'
                      Tag: ''
                     Type: 'videosource'
             WhiteBalance: 4600
         WhiteBalanceMode: 'auto'

% set(vid,'ReturnedColorSpace','rgb');
img = getsnapshot(vid);
% rgb = ycbcr2rgb(img); % don't need to convert colorspace earlier
imshow(img);
Warning: Image is too big to fit on screen; displaying at 67% 
start(vid);
data = getdata(vid);
imaqmontage(data);
delete(vid);
clear all;