function varargout = mainGUI(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mainGUI_OpeningFcn, ...
'gui_OutputFcn', @mainGUI_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 mainGUI is made visible.
function mainGUI_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 mainGUI (see VARARGIN)
handles.output = hObject;
S = imread('autumn.tif');
handles.S = S;
axes(handles.axes1);
subimage(S);
%handles.S2 = S2;
guidata(hObject, handles);
% UIWAIT makes mainGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mainGUI_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 pbStart.
function pbStart_Callback(hObject, eventdata, handles)
% hObject handle to pbStart (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
guidata(hObject, handles);
%loc = handles.api.getPosition();
set(handles.pbStart,'enable','off');
set(handles.pbStop,'enable','on');
set(handles.pbStop,'UserData',0);
fileinfo = handles.fileinfo;
numFrames = get(fileinfo, 'numberOfFrames');
FrameRate=fileinfo.FrameRate(1);
timeforframe=FrameRate/60;
y = read(fileinfo,4);
cnt_move = 0;
cnt_unmove = 0;
cntsnap = 1;
cnt=1;
[imageheight imagewidth]=size(y);
N = 5; % number of layers
T = 20; % RGB Euclidian threshold
U = 0.999; % update rate
A = 0.85; % fraction of observed colour to account for in the background
% delete('test/*.png');
% global outpuArray;
% global inputNN
% global netNNOBJ
yprev = y;% imcrop(y,loc);
xdist=10;%str2num(get(handles.edit12,'string'));
ydist=10;%str2num(get(handles.edit13,'string'));
starttime=0;
% set(handles.text20,'string',['Object Type : ']);
th=1.5;%str2num(get(handles.edit14,'string'));
vcnt=0;
lasty=0;
while cnt <= numFrames
cnt=cnt+1;
if get(handles.pbStop,'UserData')
break
else
y = read(fileinfo,cnt);
axes(handles.axes1);subimage(y);
% handles.loc = handles.api.getPosition();
%axes(handles.axes1);
%%
% y = imcrop(y,loc);
im = double(y);
im = subsample3(im, 320, 240);
if starttime~=0
starttime=timeforframe+starttime;
end
if cnt == 2
bgmodel = initLayeredBackgroundModel(im, N, T, U, A);
else
[bgmodel, foreground, bridif, coldif, shadows] = updateLayeredBackgroundModel(bgmodel, im);
r=2;
c=3;
diff = abs(y-yprev);
abs_img = mean(diff(:));
disp(abs_img);
if abs_img > th
yprev = y;
subplot(r,c,1,'parent',handles.uipanel8);
shownormimage2(im); title('Image');
%
% try
% %g1=gabor_program(im);
% %fb=FeatureBlock(im);
% catch err
% end
subplot(r,c,2,'parent',handles.uipanel8);
shownormimage2(foreground); title('Detected Foreground');
% subplot(r,c,6);
% shownormimage2(bluescreen(imfg, im)); title('Detected Object');
end
end
handles.outdata.time{cntsnap} = datestr(clock);
end
end
cla;
subimage(handles.S);
cla;
subimage(handles.S2);
delete(handles.vid);
imaqreset;
set(handles.pbStart,'enable','on');
set(handles.pbStop,'enable','off');
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
guidata(hObject, handles);
% --- Executes on button press in pbStop.
function pbStop_Callback(hObject, eventdata, handles)
% hObject handle to pbStop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.pbStart,'enable','on');
set(handles.pbStop,'enable','off');
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
set(handles.pbStop,'UserData',1);
guidata(hObject, handles);
function editAbs_Callback(hObject, eventdata, handles)
% hObject handle to editAbs (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,'String') returns contents of editAbs as text
% str2double(get(hObject,'String')) returns contents of editAbs as a double
% --- Executes during object creation, after setting all properties.
function editAbs_CreateFcn(hObject, eventdata, handles)
% hObject handle to editAbs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function editMemLeft_Callback(hObject, eventdata, handles)
% hObject handle to editMemLeft (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,'String') returns contents of editMemLeft as text
% str2double(get(hObject,'String')) returns contents of editMemLeft as a double
% --- Executes during object creation, after setting all properties.
function editMemLeft_CreateFcn(hObject, eventdata, handles)
% hObject handle to editMemLeft (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function editMemLoad_Callback(hObject, eventdata, handles)
% hObject handle to editMemLoad (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,'String') returns contents of editMemLoad as text
% str2double(get(hObject,'String')) returns contents of editMemLoad as a double
% --- Exe