在用matlab2013运行一个视觉算法的时候,出现了如下问题:
“Error using videoinput (line 319)
The FORMAT specified is not supported by this device. See IMAQHWINFO(ADAPTORNAME).”
原来是自己的摄像头支持的格式和代码中的格式不对应。
解决办法:
(1)
打开摄像头:
source.vid = videoinput('winvideo', 1);
set(source.vid,'ReturnedColorSpace','grayscale');
vidRes = get(source.vid, 'VideoResolution');
nBands = get(source.vid, 'NumberOfBands');
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );
preview(source.vid, hImage);
查看摄像头信息:
>> win_info=imaqhwinfo('winvideo')
win_info =
AdaptorDllName: [1x81 char]
AdaptorDllVersion: '4.5 (R2013a)'
AdaptorName: 'winvideo'
DeviceIDs: {[1]}
DeviceInfo: [1x1 struct]
DeviceI