试一试这个程序,调用笔记本电脑自带摄像头
vid=videoinput('winvideo');
set(vid,'TriggerRepeat',inf);
h=figure('units','normalized','menubar','none','numbertitle','off');
ha=axes('parent',h,'units','normalized','position',[.005 .7 .99 .925]);
axis off;
hb=uicontrol('parent',h,'units','normalized','position',[.01 .1 .199 .6],'string','Preview','callback',...
['hf=figure(''units'',''normalized'',''menubar'',''none'',''numbertitle'',''off'');'...
'axes(''parent'',hf,''units'',''normalized'',''position'',[.005 .007 .99 .99]);'...
'objRes=get(vid, ''VideoResolution'');'...
'nBands=get(vid,''NumberOfBands'');'...
'hImage=image(zeros(objRes(2),objRes(1),nBands));'...
'preview(vid,hImage);']);