-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow_gui.m
142 lines (123 loc) · 5.34 KB
/
window_gui.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
function varargout = window_gui(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @window_gui_OpeningFcn, ...
'gui_OutputFcn', @window_gui_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
function window_gui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = window_gui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function img_upload_Callback(hObject, eventdata, handles)
[filename,pathname]=uigetfile('*.*','Select the Input Image');
filewithpath=strcat(pathname,filename);
I = imread(filewithpath);
detector = peopleDetectorACF();
[bboxes,scores] = detect(detector,I);
axes(handles.axes1);
cond = zeros(size(bboxes,1),1);
if ~isempty(bboxes)
for i=1:(size(bboxes,1)-1)
for j=(i+1):(size(bboxes,1)-1)
dis1_v = abs(bboxes(i,1)+bboxes(i,3)-bboxes(j,1));
dis2_v = abs(bboxes(j,1)+bboxes(j,3)-bboxes(i,1));
dis1_h = abs(bboxes(i,2)-bboxes(j,2));
dis2_h = abs(bboxes(i,2)+bboxes(i,4)-bboxes(j,2)-bboxes(j,4));
if((dis1_v<75 || dis2_v<75) && (dis1_h<50 || dis2_h<50))
cond(i)=cond(i)+1;
cond(j)=cond(j)+1;
else
cond(i)=cond(i)+0;
end
end
end
end
I = insertObjectAnnotation(I,'rectangle',bboxes((cond>0),:),'danger','color','r');
I = insertObjectAnnotation(I,'rectangle',bboxes((cond==0),:),'safe','color','g');
imshow(I)
% --- Executes on button press in vid_upload.
function vid_upload_Callback(hObject, eventdata, handles)
[filename,pathname]=uigetfile('*.*','Select the Input Video');
filewithpath=strcat(pathname,filename);
videoReader = vision.VideoFileReader(filewithpath);
videoPlayer = vision.VideoPlayer('Position',[300 100 1200 500]);
detector = peopleDetectorACF('caltech-50x21');
%detector = peopleDetectorACF();
while ~isDone(videoReader)
frame = step(videoReader);
I=double(frame);
[bboxes,scores] = detect(detector,I);
cond = zeros(size(bboxes,1),1);
if ~isempty(bboxes)
for i=1:(size(bboxes,1)-1)
for j=(i+1):(size(bboxes,1)-1)
dis1_v = abs(bboxes(i,1)+bboxes(i,3)-bboxes(j,1));
dis2_v = abs(bboxes(j,1)+bboxes(j,3)-bboxes(i,1));
dis1_h = abs(bboxes(i,2)-bboxes(j,2));
dis2_h = abs(bboxes(i,2)+bboxes(i,4)-bboxes(j,2)-bboxes(j,4));
if((dis1_v<75 || dis2_v<75) && (dis1_h<50 || dis2_h<50))
cond(i)=cond(i)+1;
cond(j)=cond(j)+1;
else
cond(i)=cond(i)+0;
end
end
end
end
I = insertObjectAnnotation(I,'rectangle',bboxes((cond>0),:),'danger','color','r');
I = insertObjectAnnotation(I,'rectangle',bboxes((cond==0),:),'safe','color','g');
step(videoPlayer,I);
%frame = im2frame(I);
%writeVideo(writeObj,frame);
end
release(videoReader);
release(videoPlayer);
function countryName_Callback(hObject, eventdata, handles)
url = 'https://www.worldometers.info/coronavirus/country/';
cntry = get(handles.countryName,'String');
cntryURL = strcat(url,cntry);
target = 'Coronavirus Cases:';
confCases = urlfilter(cntryURL,target);
set(handles.caseDisplay,'String',confCases);
target2 = 'Deaths:';
dead = urlfilter(cntryURL,target2);
set(handles.deathDisplay,'String',dead);
target3 = 'Recovered:';
recov = urlfilter(cntryURL,target3);
set(handles.recoverDisplay,'String',recov);
% --- Executes during object creation, after setting all properties.
function countryName_CreateFcn(hObject, eventdata, handles)
% hObject handle to countryName (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function caseDisplay_CreateFcn(hObject, eventdata, handles)
% hObject handle to caseDisplay (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
function deathDisplay_CreateFcn(hObject, eventdata, handles)
% hObject handle to deathDisplay (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
function recoverDisplay_CreateFcn(hObject, eventdata, handles)
% hObject handle to recoverDisplay (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called