如果出现
??? 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)
- 推荐一个免费的论文查重检测软件PaperRater 2015-11-4
- 2013年四川高考分数线发布 2013-6-21
- 【存档未转换文章】寻找笔亲 2015-9-18
- 长沙地铁的一个实验:旁边的陌生人困了,你愿意给他一个肩膀吗?看完也是会心一笑~ 2016-2-24
- 四川民族学院2011届毕业生欢送晚会 - ky 2011-8-10
- 北京祝福你 2012-8-12
- 懒人购就是一个坑爹的团队 2013-3-27
- 22岁的南充女孩陈秋静是四川民族学院在校大学生 2013-3-28
- 下载无损音乐的网站 2019-12-26
- 数学作图工具软件、学习资料分享 2019-4-9