【MATLAB与机器学习】MATLAB访问本机摄像头
% MATLAB控制摄像头操作 % 获取本机中已经安装的硬件资源列表 imaqhwinfo % 建立videoinput对象 obj = videoinput(‘winvideo‘); % 设置属性 set(obj, ‘FramesPerTrigger‘, 1); set(obj, ‘TriggerRepeat‘, Inf); % 建立界面 hf = figure(‘Units‘, ‘Normalized‘, ‘Menubar‘, ‘None‘, ... ‘NumberTitle‘, ‘off‘, ‘Name‘, ‘演示拍照系统‘); ha = axes(‘Parent‘, hf, ‘Units‘, ‘Normalized‘, ... ‘Position‘, [.05 .2 .85 .7]); axis off hb1 = uicontrol(‘Parent‘, hf, ‘Units‘, ‘Normalized‘, ... ‘Position‘, [.25 .05 .2 .1], ‘String‘, ‘预览‘, ... ‘Callback‘, ... [‘objRes = get(obj, ‘‘VideoResolution‘‘);‘ ... ‘nBands = get(obj, ‘‘NumberOfBands‘‘);‘ ... ‘hImage = image(zeros(objRes(2), objRes(1), nBands));‘ ... ‘preview(obj, hImage);‘]); hb2 = uicontrol(‘Parent‘, hf, ‘Units‘, ‘Normalized‘, ... ‘Position‘, [.55 .05 .2 .1], ‘String‘, ‘拍照‘, ... ‘Callback‘, ‘imwrite(getsnapshot(obj), ‘‘im.jpg‘‘)‘);
相关推荐
wwwdownmacom 2020-09-14
wanff0 2020-07-26
cuiguanjun 2020-07-26
HongAndYi 2020-07-04
知识小屋 2020-06-24
wanff0 2020-06-14
cuiguanjun 2020-06-13
liqing 2020-06-13
algorithmlixuan 2020-06-12
faustcao 2020-06-12
zyazky 2020-06-08
cuiguanjun 2020-06-05
Canethui 2020-05-31
Canethui 2020-05-30
zyazky 2020-05-29
zyazky 2020-05-19
zyazky 2020-05-17
cuiguanjun 2020-05-17