主要内容

确定可用的设备

这个示例展示了如何识别系统上的可用设备并获取设备信息。

确定安装适配器

imaqhwinfo函数提供了一个带有InstalledAdaptors字段,列出当前系统上工具箱可以访问的所有适配器。

imaqInfo = imaqhwinfo
imaqInfo = InstalledAdaptors: {'dcam' 'winvideo'} MATLABVersion: '7.1 (R14SP3)' ToolboxName: 'Image Acquisition Toolbox' ToolboxVersion: '1.9 (R14SP3)'
imaqInfo。InstalledAdaptors
Ans = 'dcam' 'winvideo'

获取设备信息

调用imaqhwinfo使用适配器名称返回一个结构,该结构提供关于所有可访问图像采集设备的信息。

hwInfo = imaqhwinfo (“winvideo”
hwInfo = AdaptorDllName: [1x68 char] AdaptorDllVersion: '1.9 (R14SP3)' AdaptorName: 'winvideo' deviceid: {[1] [3]} DeviceInfo: [1x2 struct]
hwInfo。DeviceInfo
ans = 1x2 struct array with fields: DefaultFormat DeviceFile金宝appSupported DeviceName DeviceID VideoInputConstructor VideoDeviceConstructor SupportedFormats

关于特定设备的信息可以通过简单地索引到设备信息结构数组中来获得。

device1 = hwInfo.DeviceInfo (1)
device1 = DefaultFormat: 'RGB555_320x240' DeviceFile金宝appSupported: 0 DeviceName: 'Veo PC Camera' DeviceID: 1 VideoInputConstructor: 'videoinput('winvideo', 1)' VideoDeviceConstructor: 'imaq. 'VideoDevice('winvideo', 1)' 金宝appSupportedFormats: {1x30 cell}

设备名称字段包含图像采集设备名称。

device1。设备名称
ans = Veo电脑摄像头

的DeviceID字段包含图像采集设备标识符。

device1。的DeviceID
ans = 1

DefaultFormat字段包含图像采集设备的默认视频格式。

device1。DefaultFormat
ans = RGB555_320x240

金宝appSupportedFormats字段包含图像采集设备支持的所有有效视频格式的单元格数组。金宝app

device1。金宝appSupportedFormats
ans =列1到4“I420_128x96”“I420_160x120”“I420_176x144”“I420_320x240”列5 - 8“I420_352x240”“I420_352x288”“RGB24_128x96”“RGB24_160x120”列9到11“RGB24_176x144”“RGB24_320x240”“RGB24_352x240”列12至14“RGB24_352x288”“RGB555_128x96”“RGB555_160x120”列15通过17“RGB555_176x144”“RGB555_352x240”第18列到第21列“RGB555_352x288”“UYVY_128x96”“UYVY_160x120”“UYVY_176x144”第22列到第25列“YUY2_128x96”“YUY2_160x120”“YUY2_176x144”“YV12_176x144”“YV12_320x240”“YV12_352x240”第30列“YV12_352x288”