function varargout = motion_detection(varargin)
% MOTION_DETECTION M-file for motion_detection.fig
% MOTION_DETECTION, by itself, creates a new MOTION_DETECTION or raises the existing
% singleton*.
%
% H = MOTION_DETECTION returns the handle to a new MOTION_DETECTION or the handle to
% the existing singleton*.
%
% MOTION_DETECTION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MOTION_DETECTION.M with the given input arguments.
%
% MOTION_DETECTION('Property','Value',...) creates a new MOTION_DETECTION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before motion_detection_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to motion_detection_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
% Edit the above text to modify the response to help motion_detection
% Last Modified by GUIDE v2.5 26-Apr-2004 17:28:28
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @motion_detection_OpeningFcn, ...
'gui_OutputFcn', @motion_detection_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 motion_detection is made visible.
function motion_detection_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 motion_detection (see VARARGIN)
% Choose default command line output for motion_detection
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes motion_detection wait for user response (see UIRESUME)
% uiwait(handles.figure1);
icon1=imread('exit.jpg');
icon2=imread('plot.jpg');
icon3=imread('mov.jpg');
icon4=imread('log.jpg');
icon5=imread('start_stop.jpg');
set(handles.pushbutton4,'CData',icon1)
set(handles.pushbutton3,'CData',icon2)
set(handles.pushbutton2,'CData',icon3)
set(handles.pushbutton1,'CData',icon4)
set(handles.togglebutton1,'CData',icon5)
% --- Outputs from this function are returned to the command line.
function varargout = motion_detection_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 togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
button_state = get(hObject,'Value');
if button_state == get(hObject,'Max')
% toggle button is pressed
delete 'log.txt'
delete 'film.avi'
delete 'var.mat'
radio = get(handles.radiobutton1,'value')
if (radio==1)
sad_algorithm
else
corrolation_algorithm
end
elseif button_state == get(hObject,'Min')
% toggle button is not pressed
set(handles.togglebutton1, 'Value', 0);
end
% --- Executes on button press in pushbutton1.
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)
open 'log.txt';
% --- Executes on button press in pushbutton2.
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)
load('var')
movie(film,1,5)
movie2avi(film,'film','fps',5)
% --- Executes on button press in pushbutton3.
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)
axes(handles.axes1);
cla;
load('var')
semilogy(var_values);
grid on;
xlabel('Frame number');
ylabel('VARIANCE VALUE');
title('Motion detection using variane');
% --- Executes on button press in pushbutton4.
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)
delete 'var.mat'
exit
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
set(handles.radiobutton1, 'Value', 1);
set(handles.radiobutton2, 'Value', 0);
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton2
set(handles.radiobutton1, 'Value', 0);
set(handles.radiobutton2, 'Value', 1);
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%t = get(handles.slider1,'value');
%set(handles.valText1,'String',num2str(t));
t = get(handles.slider1,'value');
set(handles.valText1,'String',num2str(t));
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%t = get(handles.slider2,'value');
%set(handles.valText2,'String',num2str(t));
t = get(handles.slider2,'value');
set(handles.valText2,'String',num2str(t));