I need some help with my following code:
(1) I my following code when push the button the start button the camera starts , while running I want to capture image from the cam after each 5 seconds and want to save that fram in a folder.
(2) when push stop button the cam should stop capturing frames too.
function varargout = MyFERApp(varargin)gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @MyFERApp_OpeningFcn, ... 'gui_OutputFcn', @MyFERApp_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 MyFERApp is made visible.
function MyFERApp_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 MyFERApp (see VARARGIN)
% Choose default command line output for MyFERApp
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes MyFERApp wait for user response (see UIRESUME)
% uiwait(handles.figure1);
handles.output = hObject;imaqresethandles.cam = webcam(1);guidata(hObject, handles);% --- Outputs from this function are returned to the command line.
function varargout = MyFERApp_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 Start_Camera_button.
function Start_Camera_button_Callback(hObject, eventdata, handles)% hObject handle to Start_Camera_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global KeepRunning;KeepRunning=1;while KeepRunning cam = handles.cam; data = snapshot(cam); imshow(data, 'Parent', handles.axes1); hold on endguidata(hObject, handles); % --- Executes on button press in Stop_Camera_Button.
function Stop_Camera_Button_Callback(hObject, eventdata, handles)% hObject handle to Stop_Camera_Button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global KeepRunning;KeepRunning=0;guidata(hObject, handles);% --- Executes on button press in Delete_Camera_Button.
function Delete_Camera_Button_Callback(hObject, eventdata, handles)% hObject handle to Delete_Camera_Button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)cam = handles.cam;delete (cam);clear cam;guidata(hObject, handles);
Best Answer