matlab打开笔记本摄像头_matlab 调用摄像头获取视频

[Fatal Error] :-1:-1: Premature end of file.

??? Error using ==> gui_mainfcn at 41

Could not find field gui_Name in the gui_State struct in GUI M-file

Error in ==> myselfusb at 42

gui_mainfcn(gui_State, varargin{:});

以下是源程序

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

'gui_Singleton',  gui_Singleton, ...

'gui_OpeningFcn', @myselfusb_OpeningFcn, ...

'gui_OutputFcn',  @myselfusb_OutputFcn, ...

'gui_LayoutFcn',  [] , ...

'gui_Callback',   []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before myselfusb is made visible.

function myselfusb_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 myselfusb (see VARARGIN)

% Choose default command line output for myselfusb

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes myselfusb wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = myselfusb_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)

% Get default command line output from handles structure

varargout{1} = handles.output;

% --- Executes on button press in pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton1 (see GCBO)

h = waitbar(0.1,'Please wait, check hardware......');

global vid

vid = videoinput('winvideo',1);

vid_src=getselectedsource(vid);

data = getsnapshot(vid);

waitbar(0.5,h,'Please wait, initialize the window');

set(vid,'TriggerRepeat',Inf);

set(vid,'FramesPerTrigger',1);

set(vid,'FrameGrabInterval',1);

vidRes = get(vid, 'VideoResolution');

nBands = get(vid, 'NumberOfBands');

axes(handles.axes1);

waitbar(0.8,h,'Please wait, initialize the window');

hImage = image( zeros(vidRes(2), vidRes(1), nBands) );

% Display the video data in your GUI.

axes(handles.axes1);

waitbar(1.0,h,'Please wait, initialize the window');

close(h);

preview(vid, hImage);

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --- Executes during object creation, after setting all properties.

function axes1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to axes1 (see GCBO)

set(hObject,'xTick',[]);

set(hObject,'ytick',[]);

set(hObject,'box','on');

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes1

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton3 (see GCBO)

global vid

frame=getsnapshot(vid);

global numofshot

global str

str=['capture' num2str(numofshot),'.jpg'];

imwrite(frame,str,'jpg');

numofshot=numofshot+1;

axes(handles.axes1);

image(frame);

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值