基于Matlab调用摄像头

简介

针对本机(HP 笔记本)自带的摄像头,通过Matlab命令调用并预览摄像头。

代码

 % By lyqmath
clc; clear all; close all;
vid = videoinput('winvideo', 1, 'YUY2_640x480');
set(vid,'ReturnedColorSpace','rgb');
vidRes=get(vid,'VideoResolution');
width=vidRes(1);
height=vidRes(2);
nBands=get(vid,'NumberOfBands');
figure('Name', 'Matlab调用摄像头 By Lyqmath', 'NumberTitle', 'Off', 'ToolBar', 'None', 'MenuBar', 'None');
hImage=image(zeros(vidRes(2),vidRes(1),nBands));
preview(vid,hImage);

结果

 

你可能感兴趣的:(图像模式识别)