如果出现
??? Undefined function or method 'videoinput' for input arguments of type 'char'.
则应该安装 Image Acquisition Toolbox 工具箱,因为 videoinput 这个函数在 Image Acquisition Toolbox 工具箱里面
下面贴出matlab下双摄像头截图的代码,fig文件内容无法贴出,下面是与fig对应的m文件代码,仅供参考。
function varargout = camera(varargin)
% CAMERA M-file for camera.fig
% CAMERA, by itself, creates a new CAMERA or raises the existing
% singleton*.
%
% H = CAMERA returns the handle to a new CAMERA or the handle to
% the existing singleton*.
%
% CAMERA('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CAMERA.M with the given input arguments.
%
% CAMERA('Property','Value',...) creates a new CAMERA or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before camera_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to camera_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @camera_OpeningFcn, ...
'gui_OutputFcn', @camera_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
function camera_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to camera (see VARARGIN)
handles.output = hObject;
guidata(hObject, handles);
% uiwait(handles.figure1);
function varargout = camera_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
varargout{1} = handles.output;
%预览摄像机1
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
vid1=videoinput('winvideo',1,'YUY2_640x480');
vidRes1=get(vid1,'VideoResolution');
nBands1=get(vid1,'NumberOfBands');
set(vid1,'ReturnedColorSpace','rgb');
himage1=imshow(zeros(vidRes1(2),vidRes1(1),nBands1));
preview(vid1,himage1);
%handles.vid1=vid1;
%guidata(hObject,handles);
%预览摄像机2
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%global vid2;
axes(handles.axes2);
vid2=videoinput('winvideo',2,'YUY2_640x480');
vidRes2=get(vid2,'VideoResolution');
nBands2=get(vid2,'NumberOfBands');
set(vid2,'ReturnedColorSpace','rgb');
himage2=imshow(zeros(vidRes2(2),vidRes2(1),nBands2));
preview(vid2,himage2);
%handles.vid21=vid2;
%guidata(hObject,handles);
%采集摄像机1&2
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%global vid1;
%vid_1=vid1;
axes(handles.axes1);
cla;
vid_1=videoinput('winvideo',1,'YUY2_320x240');
vidRes1=get(vid_1,'VideoResolution')
nBands1=get(vid_1,'NumberOfBands')
set(vid_1,'ReturnedColorSpace','rgb');
himage1=imshow(zeros(vidRes1(2),vidRes1(1),nBands1));
preview(vid_1,himage1);
start(vid_1)
figure
%for i=1:20
data1=getdata(vid_1,1);
%wait(vid1,5);
%subplot(4,5,i);
imshow(data1);
%end
stop(vid_1)
a=toc
cla;
vidRes2=get(vid_2,'VideoResolution')
nBands2=get(vid_2,'NumberOfBands')
set(vid_2,'ReturnedColorSpace','rgb');
himage2=imshow(zeros(vidRes2(2),vidRes2(1),nBands2));
preview(vid_2,himage2);
start(vid_2)
figure
%for j=1:20
data2=getdata(vid_2,1);
%wait(vid2,5);
%subplot(4,5,j);
imshow(data2);
%end
stop(vid_2)
%采集摄像机1
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
cla;
vid1=videoinput('winvideo',1,'YUY2_320x240');
vidRes1=get(vid1,'VideoResolution')
nBands1=get(vid1,'NumberOfBands')
set(vid1,'ReturnedColorSpace','rgb');
himage1=imshow(zeros(vidRes1(2),vidRes1(1),nBands1));
preview(vid1,himage1);
%for i=1:20
data1=getdata(vid1,1);
%wait(vid1,5);
%subplot(4,5,i);
imshow(data1);
%imwrite(data1,strcat('C:\Users\bme\Documents\MATLAB\new\','1.bmp'),'bmp');
%end
stop(vid1)
%采集摄像机2
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
cla;
vidRes2=get(vid2,'VideoResolution')
nBands2=get(vid2,'NumberOfBands')
set(vid2,'ReturnedColorSpace','rgb');
himage2=imshow(zeros(vidRes2(2),vidRes2(1),nBands2));
preview(vid2,himage2);
figure
%for i=1:20
data2=getdata(vid2,1);
%wait(vid1,5);
% subplot(4,5,i);
imshow(data2);
%end
stop(vid2)
- 【Mop人才太多了】军训的唯一风景线,让我深深地震惊了! 2011-12-17
- 22岁的南充女孩陈秋静是四川民族学院在校大学生 2013-3-28
- 四川民族学院根据工作需要,经研究,决定面向社会招聘驾驶员1名 2019-5-10
- 帮我朋友找一个有缘人 2019-11-29
- b区这家小卖部 2017-11-27
- 杜云生销售演讲视频01 - 口才 销售 杜云生 创富 2011-7-22
- གྲོས་འཆམ་བྱུང་གྱི་དྲ་ཚིགས་ཐད་ཞིག་ཡིན་རྒྱབ་སྐྱོར་བྱ་རྒྱུ་བོད་ཡིག་ཡིག་གཟུགས་CSS3། 2016-7-4
- 新来的~~ 2012-9-9
- 大学生志愿服务总队“我心中的志愿者,我的志愿生活”演讲比赛圆满结束 2019-12-8
- 经济数学(课件) 2011-7-17