[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)