.
675 |
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool.fig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/LabelingTool/LabelingTool.fig
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool.m:
--------------------------------------------------------------------------------
1 | function varargout = LabelingTool(varargin)
2 | gui_Singleton = 1;
3 | gui_State = struct('gui_Name', mfilename, ...
4 | 'gui_Singleton', gui_Singleton, ...
5 | 'gui_OpeningFcn', @LabelingTool_OpeningFcn, ...
6 | 'gui_OutputFcn', @LabelingTool_OutputFcn, ...
7 | 'gui_LayoutFcn', [] , ...
8 | 'gui_Callback', []);
9 | if nargin && ischar(varargin{1})
10 | gui_State.gui_Callback = str2func(varargin{1});
11 | end
12 |
13 | if nargout
14 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
15 | else
16 | gui_mainfcn(gui_State, varargin{:});
17 | end
18 | % End initialization code - DO NOT EDIT
19 | end
20 |
21 | % --- Outputs from this function are returned to the command line.
22 | function varargout = LabelingTool_OutputFcn(hObject, eventdata, handles)
23 | varargout{1} = handles.output;
24 |
25 | % initialization code
26 | end
27 |
28 |
29 | % --- Executes just before LabelingTool is made visible.
30 | function LabelingTool_OpeningFcn(hObject, eventdata, handles, varargin)
31 | handles.output = hObject;
32 | set(gcf,'pointer','fullcrosshair')
33 | guidata(hObject, handles);
34 |
35 | end
36 |
37 |
38 | % --- Executes on button press in pushbutton1.
39 | function pushbutton1_Callback(hObject, eventdata, handles)
40 | global idx imgs Visibility Status CoordinateX CoordinateY draw_circle;
41 |
42 | dName_img = uigetdir();
43 | if dName_img ~= 0
44 | set(handles.text2, 'String', dName_img); % set path on ui
45 |
46 | idx = 1;% current frame index
47 | CoordinateX(1:10000)= -1; % Array to save each frame Coordinate X
48 | CoordinateY(1:10000)= -1; % Array to save each frame Coordinate Y
49 | Status(1:10000)= 0; % Array to save each frame status
50 | Visibility(1:10000)= 1; % Array to save each frame visibility
51 | draw_circle = false; % Flag to check if the point be show on axes
52 |
53 | % save all files path string array
54 | imgs = getAllFiles(dName_img);
55 | guidata(hObject, handles);
56 |
57 |
58 | axes(handles.axes1); % set current axes to axes1
59 | %show image on axes
60 | imageHandle = imshow(imgs{idx});
61 |
62 | % assign the ButtonDownFcn to the image handle
63 | set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
64 |
65 | % show path on ui
66 | set(handles.text3, 'String', imgs{idx});
67 |
68 | %check if Label.csv in this path, if yes, load and show the data
69 | if exist(strcat(dName_img,'/Label.csv'), 'file') == 2 % value 2 means file exist
70 | fid = fopen(strcat(dName_img,'/Label.csv'));
71 | out = textscan(fid,'%s%d%f%f%d','Headerlines',1,'delimiter',',');
72 | fclose(fid);
73 |
74 | for i = 1:size(imgs)
75 | Visibility(i) = out{2}(i);
76 | CoordinateX(i) = out{3}(i);
77 | CoordinateY(i) = out{4}(i);
78 | Status(i) = out{5}(i);
79 | end
80 | end
81 | end
82 |
83 | end
84 |
85 |
86 | % Get mouse click coordinates function, tutorial: https://stackoverflow.com/questions/14684577/matlab-how-to-get-mouse-click-coordinates/14685313
87 | function ImageClickCallback ( objectHandle , eventData)
88 |
89 | global idx CoordinateX CoordinateY draw_circle Circle
90 |
91 | axesHandle = get(objectHandle,'Parent');
92 |
93 | % get mouse click coordinates x, y
94 | coordinates = get(axesHandle,'CurrentPoint');
95 | x = coordinates(1,1);
96 | y = coordinates(1,2);
97 |
98 | % save x, y to global variable Coordinate
99 | CoordinateX(idx) = round(x);
100 | CoordinateY(idx) = round(y);
101 |
102 | % since only a circle can be plot in axes, so we need to check if we had draw the circle in axes, if yes, we need to delete it
103 | radius = 1;
104 | if draw_circle == true
105 | delete(Circle);
106 | end
107 |
108 | %draw the circle on axes
109 | Circle = viscircles([x y],radius,'Color','r');
110 | draw_circle = true;
111 |
112 | end
113 |
114 |
115 |
116 | % get all *.jpg file function, refer to https://cn.mathworks.com/matlabcentral/fileexchange/48238-nonstationary-extreme-value-analysis--neva--toolbox?focused=5028815&tab=function
117 | function fileList = getAllFiles(dirName)
118 | dirData = dir(strcat(dirName,'/*.jpg'));
119 | dirIndex = [dirData.isdir];
120 | fileList = {dirData(~dirIndex).name}';
121 |
122 | if ~isempty(fileList)
123 | fileList = cellfun(@(x) fullfile(dirName,x),fileList,'UniformOutput',false);
124 | end
125 |
126 | subDirs = {dirData(dirIndex).name};
127 | validIndex = ~ismember(subDirs,{'.','..'});
128 |
129 | for iDir = find(validIndex)
130 | nextDir = fullfile(dirName,subDirs{iDir});
131 | fileList = [fileList; getAllFiles(nextDir)];
132 | end
133 |
134 | end
135 |
136 |
137 |
138 | % --- Executes on key press with focus on figure1
139 | function figure1_WindowKeyPressFcn(hObject, eventdata, handles)
140 |
141 | global idx imgs draw_circle CoordinateX CoordinateY Circle Visibility Status
142 |
143 | switch eventdata.Key
144 | case 'leftarrow' % show previous frame
145 | if idx > 1 % idx range should be 1~lenght(imgs)
146 | idx = idx - 1;
147 | guidata(hObject, handles);
148 | % set current axes to axes1
149 | axes(handles.axes1);
150 | %show image on axes
151 | imageHandle = imshow(imgs{idx});
152 | % assign the ButtonDownFcn to the image handle
153 | set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
154 |
155 | % default all of radio buttons is enable
156 | set(handles.frying, 'Enable', 'on');
157 | set(handles.hit, 'Enable', 'on');
158 | set(handles.bouncing, 'Enable', 'on');
159 |
160 |
161 | if Visibility(idx) == 0 % disable all of radio buttons
162 | set(handles.no_ball, 'Value', 1);
163 | set(handles.frying, 'Enable', 'off');
164 | set(handles.hit, 'Enable', 'off');
165 | set(handles.bouncing, 'Enable', 'off');
166 | elseif Visibility(idx) == 1 % set easy_identification radio button to 1
167 | set(handles.easy_identification, 'Value', 1);
168 | elseif Visibility(idx) == 2 % set hard_identification radio button to 1
169 | set(handles.hard_identification, 'Value', 1);
170 | elseif Visibility(idx) == 3 % set occluded_ball radio button to 1
171 | set(handles.occluded_ball, 'Value', 1);
172 | end
173 |
174 | if Status(idx) == 0 % set frying radio button to 1
175 | set(handles.frying, 'Value', 1);
176 | elseif Status(idx) == 1 % set hit radio button to 1
177 | set(handles.hit, 'Value', 1);
178 | elseif Status(idx) == 2 % set bouncing radio button to 1
179 | set(handles.bouncing, 'Value', 1);
180 | end
181 |
182 | set(handles.text3, 'String', imgs{idx}); % show path on text3
183 |
184 | if CoordinateX(idx)==-1 && CoordinateY(idx)==-1
185 | set(handles.text3, 'ForegroundColor', 'r'); % for reminding, if the frame do not be labeled, the path will be red.
186 | draw_circle = false;
187 | else
188 | set(handles.text3, 'ForegroundColor', 'b'); % for reminding, if the frame do not be labeled, the path will be red
189 | Circle = viscircles([CoordinateX(idx) CoordinateY(idx) ],1,'Color','r');
190 | draw_circle = true;
191 | end
192 | end
193 |
194 | case 'rightarrow' % show next frame
195 | [m,n] = size(imgs); % get images size
196 | if idx < m % idx range should be 1~lenght(imgs)
197 |
198 | idx = idx + 1;
199 | guidata(hObject, handles);
200 | % set current axes to axes1
201 | axes(handles.axes1);
202 | %show image on axes
203 | imageHandle = imshow(imgs{idx});
204 | % assign the ButtonDownFcn to the image handle
205 | set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
206 |
207 | % default all of radio buttons is enable
208 | set(handles.frying, 'Enable', 'on');
209 | set(handles.hit, 'Enable', 'on');
210 | set(handles.bouncing, 'Enable', 'on');
211 |
212 | if Visibility(idx) == 0 % disable all of radio buttons
213 | set(handles.no_ball, 'Value', 1);
214 | set(handles.frying, 'Enable', 'off');
215 | set(handles.hit, 'Enable', 'off');
216 | set(handles.bouncing, 'Enable', 'off');
217 | elseif Visibility(idx) == 1 % set easy_identification radio button to 1
218 | set(handles.easy_identification, 'Value', 1);
219 | elseif Visibility(idx) == 2 % set hard_identification radio button to 1
220 | set(handles.hard_identification, 'Value', 1);
221 | elseif Visibility(idx) == 3 % set occluded_ball radio button to 1
222 | set(handles.occluded_ball, 'Value', 1);
223 | end
224 |
225 | if Status(idx) == 0 % set frying radio button to 1
226 | set(handles.frying, 'Value', 1);
227 | elseif Status(idx) == 1 % set hit radio button to 1
228 | set(handles.hit, 'Value', 1);
229 | elseif Status(idx) == 2 % set bouncing radio button to 1
230 | set(handles.bouncing, 'Value', 1);
231 | end
232 |
233 |
234 | set(handles.text3, 'String', imgs{idx}); % show path on text3
235 | if CoordinateX(idx)==-1 && CoordinateY(idx)==-1
236 | set(handles.text3, 'ForegroundColor', 'r'); % for reminding, if the frame do not be labeled, the path will be as red.
237 | draw_circle = false;
238 | else
239 | set(handles.text3, 'ForegroundColor', 'b'); % for reminding, if the frame do not be labeled, the path will be as blue.
240 | Circle = viscircles([CoordinateX(idx) CoordinateY(idx) ],1,'Color','r');
241 | draw_circle = true;
242 | end
243 | end
244 | end
245 |
246 | end
247 |
248 |
249 | % --- Executes on button press in pushbutton2.
250 | function pushbutton2_Callback(hObject, eventdata, handles)
251 |
252 | global imgs CoordinateX CoordinateY Visibility Status
253 |
254 | % for reminding, check if there have Coordinates dont be labeled
255 | alert = false;
256 | for i = 1:size(imgs)
257 | if Visibility(i) ~= 0
258 | if CoordinateX(i)==-1 || CoordinateY(i) ==-1
259 | alert = true;
260 | Path = strsplit(char(imgs(i)),'/');
261 | fileName = Path{length(Path)};
262 | warndlg(strcat(fileName, 'Visibility is not No BALL, but Coordinates dont be labeled') ,'Alert');
263 | break;
264 | end
265 | end
266 | end
267 |
268 | % if all of images be labeled correctly, output Label.csv
269 | if alert == false
270 | disp(strcat(get(handles.text2, 'String')))
271 | fid = fopen(strcat(get(handles.text2, 'String'),'\Label.csv'),'w');
272 | fprintf(fid, 'file name,visibility,x-coordinate,y-coordinate,status\n'); % Label.csv header
273 | for i = 1:size(imgs)
274 | Path = strsplit(char(imgs(i)),'\');
275 | fileName = Path{length(Path)};
276 | if Visibility(i)== 0
277 | fprintf(fid, '%s,0,,,\n', fileName);
278 | else
279 | fprintf(fid, '%s,%d,%d,%d,%d\n', fileName, Visibility(i), CoordinateX(i), CoordinateY(i), Status(i));
280 |
281 | end
282 | end
283 | fclose(fid);
284 | end
285 |
286 |
287 | end
288 |
289 |
290 | % --- Executes when selected object is changed in VisibilityGroup.
291 | function VisibilityGroup_SelectionChangedFcn(hObject, eventdata, handles)
292 | global idx Visibility
293 |
294 | % default all of radiobutton as enable
295 | set(handles.frying, 'Enable', 'on');
296 | set(handles.hit, 'Enable', 'on');
297 | set(handles.bouncing, 'Enable', 'on');
298 |
299 | switch(get(eventdata.NewValue,'Tag'));
300 | case 'no_ball' % turn all of radiobutton as disable
301 | Visibility(idx) = 0;
302 | set(handles.frying, 'Enable', 'off');
303 | set(handles.hit, 'Enable', 'off');
304 | set(handles.bouncing, 'Enable', 'off');
305 | case 'easy_identification'
306 | Visibility(idx) = 1;
307 | case 'hard_identification'
308 | Visibility(idx) = 2;
309 | case 'occluded_ball'
310 | Visibility(idx) = 3;
311 | end
312 |
313 | end
314 |
315 |
316 | % --- Executes when selected object is changed in StatusGroup.
317 | function StatusGroup_SelectionChangedFcn(hObject, eventdata, handles)
318 | global idx Status
319 | switch(get(eventdata.NewValue,'Tag'));
320 | case 'frying'
321 | Status(idx) = 0;
322 | case 'hit'
323 | Status(idx) = 1;
324 | case 'bouncing'
325 | Status(idx) = 2;
326 | end
327 | end
328 |
329 |
330 |
331 | % --- Executes on key press with focus on figure1 or any of its controls.
332 | function figure1_KeyPressFcn(hObject, eventdata, handles)
333 | end
334 |
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool.m~:
--------------------------------------------------------------------------------
1 | function varargout = LabelingTool(varargin)
2 | gui_Singleton = 1;
3 | gui_State = struct('gui_Name', mfilename, ...
4 | 'gui_Singleton', gui_Singleton, ...
5 | 'gui_OpeningFcn', @LabelingTool_OpeningFcn, ...
6 | 'gui_OutputFcn', @LabelingTool_OutputFcn, ...
7 | 'gui_LayoutFcn', [] , ...
8 | 'gui_Callback', []);
9 | if nargin && ischar(varargin{1})
10 | gui_State.gui_Callback = str2func(varargin{1});
11 | end
12 |
13 | if nargout
14 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
15 | else
16 | gui_mainfcn(gui_State, varargin{:});
17 | end
18 | % End initialization code - DO NOT EDIT
19 | end
20 |
21 | % --- Outputs from this function are returned to the command line.
22 | function varargout = LabelingTool_OutputFcn(hObject, eventdata, handles)
23 | varargout{1} = handles.output;
24 |
25 | % initialization code
26 | end
27 |
28 |
29 | % --- Executes just before LabelingTool is made visible.
30 | function LabelingTool_OpeningFcn(hObject, eventdata, handles, varargin)
31 | handles.output = hObject;
32 | set(gcf,'pointer','fullcrosshair')
33 | guidata(hObject, handles);
34 |
35 | end
36 |
37 |
38 | % --- Executes on button press in pushbutton1.
39 | function pushbutton1_Callback(hObject, eventdata, handles)
40 | global idx imgs Visibility Status CoordinateX CoordinateY draw_circle;
41 |
42 | dName_img = uigetdir('/media/andersen/D/Clip1');
43 | if dName_img ~= 0
44 | set(handles.text2, 'String', dName_img); % set path on ui
45 |
46 | idx = 1;% current frame index
47 | CoordinateX(1:10000)= -1; % Array to save each frame Coordinate X
48 | CoordinateY(1:10000)= -1; % Array to save each frame Coordinate Y
49 | Status(1:10000)= 0; % Array to save each frame status
50 | Visibility(1:10000)= 1; % Array to save each frame visibility
51 | draw_circle = false; % Flag to check if the point be show on axes
52 |
53 | % save all files path string array
54 | imgs = getAllFiles(dName_img);
55 | guidata(hObject, handles);
56 |
57 |
58 | axes(handles.axes1); % set current axes to axes1
59 | %show image on axes
60 | imageHandle = imshow(imgs{idx});
61 |
62 | % assign the ButtonDownFcn to the image handle
63 | set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
64 |
65 | % show path on ui
66 | set(handles.text3, 'String', imgs{idx});
67 |
68 | %check if Label.csv in this path, if yes, load and show the data
69 | if exist(strcat(dName_img,'/Label.csv'), 'file') == 2 % value 2 means file exist
70 | fid = fopen(strcat(dName_img,'/Label.csv'));
71 | out = textscan(fid,'%s%d%f%f%d','Headerlines',1,'delimiter',',');
72 | fclose(fid);
73 |
74 | for i = 1:size(imgs)
75 | Visibility(i) = out{2}(i);
76 | CoordinateX(i) = out{3}(i);
77 | CoordinateY(i) = out{4}(i);
78 | Status(i) = out{5}(i);
79 | end
80 | end
81 | end
82 |
83 | end
84 |
85 |
86 | % Get mouse click coordinates function, tutorial: https://stackoverflow.com/questions/14684577/matlab-how-to-get-mouse-click-coordinates/14685313
87 | function ImageClickCallback ( objectHandle , eventData)
88 |
89 | global idx CoordinateX CoordinateY draw_circle Circle
90 |
91 | axesHandle = get(objectHandle,'Parent');
92 |
93 | % get mouse click coordinates x, y
94 | coordinates = get(axesHandle,'CurrentPoint');
95 | x = coordinates(1,1);
96 | y = coordinates(1,2);
97 |
98 | % save x, y to global variable Coordinate
99 | CoordinateX(idx) = round(x);
100 | CoordinateY(idx) = round(y);
101 |
102 | % since only a circle can be plot in axes, so we need to check if we had draw the circle in axes, if yes, we need to delete it
103 | radius = 1;
104 | if draw_circle == true
105 | delete(Circle);
106 | end
107 |
108 | %draw the circle on axes
109 | Circle = viscircles([x y],radius,'Color','r');
110 | draw_circle = true;
111 |
112 | end
113 |
114 |
115 |
116 | % get all *.jpg file function, refer to https://cn.mathworks.com/matlabcentral/fileexchange/48238-nonstationary-extreme-value-analysis--neva--toolbox?focused=5028815&tab=function
117 | function fileList = getAllFiles(dirName)
118 | dirData = dir(strcat(dirName,'/*.jpg'));
119 | dirIndex = [dirData.isdir];
120 | fileList = {dirData(~dirIndex).name}';
121 |
122 | if ~isempty(fileList)
123 | fileList = cellfun(@(x) fullfile(dirName,x),fileList,'UniformOutput',false);
124 | end
125 |
126 | subDirs = {dirData(dirIndex).name};
127 | validIndex = ~ismember(subDirs,{'.','..'});
128 |
129 | for iDir = find(validIndex)
130 | nextDir = fullfile(dirName,subDirs{iDir});
131 | fileList = [fileList; getAllFiles(nextDir)];
132 | end
133 |
134 | end
135 |
136 |
137 |
138 | % --- Executes on key press with focus on figure1
139 | function figure1_WindowKeyPressFcn(hObject, eventdata, handles)
140 |
141 | global idx imgs draw_circle CoordinateX CoordinateY Circle Visibility Status
142 |
143 | switch eventdata.Key
144 | case 'leftarrow' % show previous frame
145 | if idx > 1 % idx range should be 1~lenght(imgs)
146 | idx = idx - 1;
147 | guidata(hObject, handles);
148 | % set current axes to axes1
149 | axes(handles.axes1);
150 | %show image on axes
151 | imageHandle = imshow(imgs{idx});
152 | % assign the ButtonDownFcn to the image handle
153 | set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
154 |
155 | % default all of radio buttons is enable
156 | set(handles.frying, 'Enable', 'on');
157 | set(handles.hit, 'Enable', 'on');
158 | set(handles.bouncing, 'Enable', 'on');
159 |
160 |
161 | if Visibility(idx) == 0 % disable all of radio buttons
162 | set(handles.no_ball, 'Value', 1);
163 | set(handles.frying, 'Enable', 'off');
164 | set(handles.hit, 'Enable', 'off');
165 | set(handles.bouncing, 'Enable', 'off');
166 | elseif Visibility(idx) == 1 % set easy_identification radio button to 1
167 | set(handles.easy_identification, 'Value', 1);
168 | elseif Visibility(idx) == 2 % set hard_identification radio button to 1
169 | set(handles.hard_identification, 'Value', 1);
170 | elseif Visibility(idx) == 3 % set occluded_ball radio button to 1
171 | set(handles.occluded_ball, 'Value', 1);
172 | end
173 |
174 | if Status(idx) == 0 % set frying radio button to 1
175 | set(handles.frying, 'Value', 1);
176 | elseif Status(idx) == 1 % set hit radio button to 1
177 | set(handles.hit, 'Value', 1);
178 | elseif Status(idx) == 2 % set bouncing radio button to 1
179 | set(handles.bouncing, 'Value', 1);
180 | end
181 |
182 | set(handles.text3, 'String', imgs{idx}); % show path on text3
183 |
184 | if CoordinateX(idx)==-1 && CoordinateY(idx)==-1
185 | set(handles.text3, 'ForegroundColor', 'r'); % for reminding, if the frame do not be labeled, the path will be red.
186 | draw_circle = false;
187 | else
188 | set(handles.text3, 'ForegroundColor', 'b'); % for reminding, if the frame do not be labeled, the path will be red
189 | Circle = viscircles([CoordinateX(idx) CoordinateY(idx) ],1,'Color','r');
190 | draw_circle = true;
191 | end
192 | end
193 |
194 | case 'rightarrow' % show next frame
195 | [m,n] = size(imgs); % get images size
196 | if idx < m % idx range should be 1~lenght(imgs)
197 |
198 | idx = idx + 1;
199 | guidata(hObject, handles);
200 | % set current axes to axes1
201 | axes(handles.axes1);
202 | %show image on axes
203 | imageHandle = imshow(imgs{idx});
204 | % assign the ButtonDownFcn to the image handle
205 | set(imageHandle,'ButtonDownFcn',@ImageClickCallback);
206 |
207 | % default all of radio buttons is enable
208 | set(handles.frying, 'Enable', 'on');
209 | set(handles.hit, 'Enable', 'on');
210 | set(handles.bouncing, 'Enable', 'on');
211 |
212 | if Visibility(idx) == 0 % disable all of radio buttons
213 | set(handles.no_ball, 'Value', 1);
214 | set(handles.frying, 'Enable', 'off');
215 | set(handles.hit, 'Enable', 'off');
216 | set(handles.bouncing, 'Enable', 'off');
217 | elseif Visibility(idx) == 1 % set easy_identification radio button to 1
218 | set(handles.easy_identification, 'Value', 1);
219 | elseif Visibility(idx) == 2 % set hard_identification radio button to 1
220 | set(handles.hard_identification, 'Value', 1);
221 | elseif Visibility(idx) == 3 % set occluded_ball radio button to 1
222 | set(handles.occluded_ball, 'Value', 1);
223 | end
224 |
225 | if Status(idx) == 0 % set frying radio button to 1
226 | set(handles.frying, 'Value', 1);
227 | elseif Status(idx) == 1 % set hit radio button to 1
228 | set(handles.hit, 'Value', 1);
229 | elseif Status(idx) == 2 % set bouncing radio button to 1
230 | set(handles.bouncing, 'Value', 1);
231 | end
232 |
233 |
234 | set(handles.text3, 'String', imgs{idx}); % show path on text3
235 | if CoordinateX(idx)==-1 && CoordinateY(idx)==-1
236 | set(handles.text3, 'ForegroundColor', 'r'); % for reminding, if the frame do not be labeled, the path will be as red.
237 | draw_circle = false;
238 | else
239 | set(handles.text3, 'ForegroundColor', 'b'); % for reminding, if the frame do not be labeled, the path will be as blue.
240 | Circle = viscircles([CoordinateX(idx) CoordinateY(idx) ],1,'Color','r');
241 | draw_circle = true;
242 | end
243 | end
244 | end
245 |
246 | end
247 |
248 |
249 | % --- Executes on button press in pushbutton2.
250 | function pushbutton2_Callback(hObject, eventdata, handles)
251 |
252 | global imgs CoordinateX CoordinateY Visibility Status
253 |
254 | % for reminding, check if there have Coordinates dont be labeled
255 | alert = false;
256 | for i = 1:size(imgs)
257 | if Visibility(i) ~= 0
258 | if CoordinateX(i)==-1 || CoordinateY(i) ==-1
259 | alert = true;
260 | Path = strsplit(char(imgs(i)),'/');
261 | fileName = Path{length(Path)};
262 | warndlg(strcat(fileName, 'Visibility is not No BALL, but Coordinates dont be labeled') ,'Alert');
263 | break;
264 | end
265 | end
266 | end
267 |
268 | % if all of images be labeled correctly, output Label.csv
269 | if alert == false
270 | fid = fopen(strcat(get(handles.text2, 'String'),'/Label.csv'),'w');
271 | fprintf(fid, 'file name,visibility,x-coordinate,y-coordinate,status\n'); % Label.csv header
272 | for i = 1:size(imgs)
273 | Path = strsplit(char(imgs(i)),'/');
274 | fileName = Path{length(Path)};
275 | if Visibility(i)== 0
276 | fprintf(fid, '%s,0,,,\n', fileName);
277 | else
278 | fprintf(fid, '%s,%d,%d,%d,%d\n', fileName, Visibility(i), CoordinateX(i), CoordinateY(i), Status(i));
279 |
280 | end
281 | end
282 | fclose(fid);
283 | end
284 |
285 |
286 | end
287 |
288 |
289 | % --- Executes when selected object is changed in VisibilityGroup.
290 | function VisibilityGroup_SelectionChangedFcn(hObject, eventdata, handles)
291 | global idx Visibility
292 |
293 | % default all of radiobutton as enable
294 | set(handles.frying, 'Enable', 'on');
295 | set(handles.hit, 'Enable', 'on');
296 | set(handles.bouncing, 'Enable', 'on');
297 |
298 | switch(get(eventdata.NewValue,'Tag'));
299 | case 'no_ball'
300 | Visibility(idx) = 0;
301 | set(handles.frying, 'Enable', 'off');
302 | set(handles.hit, 'Enable', 'off');
303 | set(handles.bouncing, 'Enable', 'off');
304 | case 'easy_identification'
305 | Visibility(idx) = 1;
306 | case 'hard_identification'
307 | Visibility(idx) = 2;
308 | case 'occluded_ball'
309 | Visibility(idx) = 3;
310 | end
311 |
312 | end
313 |
314 |
315 | % --- Executes when selected object is changed in StatusGroup.
316 | function StatusGroup_SelectionChangedFcn(hObject, eventdata, handles)
317 | global idx Status
318 |
319 | switch(get(eventdata.NewValue,'Tag'));
320 | case 'frying'
321 | Status(idx) = 0;
322 | case 'hit'
323 | Status(idx) = 1;
324 | case 'bouncing'
325 | Status(idx) = 2;
326 | end
327 | end
328 |
329 |
330 |
331 | % --- Executes on key press with focus on figure1 or any of its controls.
332 | function figure1_KeyPressFcn(hObject, eventdata, handles)
333 | end
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool.prj:
--------------------------------------------------------------------------------
1 |
2 |
3 | LabelingTool
4 |
5 |
6 | 1.0
7 | NOL
8 |
9 | NCTU
10 |
11 |
12 |
13 |
14 | \NCTU\LabelingTool\
15 | option.installpath.programfiles
16 |
17 |
18 |
19 | ${PROJECT_ROOT}\LabelingTool\for_testing
20 | ${PROJECT_ROOT}\LabelingTool\for_redistribution_files_only
21 | ${PROJECT_ROOT}\LabelingTool\for_redistribution
22 | ${PROJECT_ROOT}\LabelingTool
23 | false
24 |
25 | subtarget.standalone
26 |
27 | true
28 | false
29 | false
30 | MyAppInstaller_web
31 | MyAppInstaller_mcr
32 | MyAppInstaller_app
33 | true
34 | false
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 | ${PROJECT_ROOT}\LabelingTool.m
69 |
70 |
71 | ${PROJECT_ROOT}\LabelingTool.fig
72 |
73 |
74 |
75 |
76 | G:\碩論備份\20180309\LabelingTool\LabelingTool\for_testing\splash.png
77 | G:\碩論備份\20180309\LabelingTool\LabelingTool\for_testing\LabelingTool.exe
78 | G:\碩論備份\20180309\LabelingTool\LabelingTool\for_testing\readme.txt
79 |
80 |
81 |
82 | C:\Program Files\MATLAB\R2017a
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | true
92 |
93 |
94 |
95 |
96 | true
97 |
98 |
99 |
100 |
101 | true
102 |
103 |
104 |
105 |
106 | true
107 |
108 |
109 |
110 |
111 | false
112 | false
113 | true
114 | false
115 | false
116 | false
117 | false
118 | false
119 | 6.2
120 | false
121 | true
122 | win64
123 | true
124 |
125 |
126 |
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/PackagingLog.html:
--------------------------------------------------------------------------------
1 |
2 | mcc -o LabelingTool -W WinMain:LabelingTool -T link:exe -d G:\碩論備份\20180309\LabelingTool\LabelingTool\for_testing -v G:\碩論備份\20180309\LabelingTool\LabelingTool.m -a G:\碩論備份\20180309\LabelingTool\LabelingTool.fig -r 'C:\Program Files\MATLAB\R2017a\toolbox\compiler\Resources\default_icon.ico'
3 | Compiler version: 6.4 (R2017a)
4 |
5 | Dependency analysis by REQUIREMENTS.
6 |
7 | Parsing file "G:\碩論備份\20180309\LabelingTool\LabelingTool.m"
8 | (Referenced from: "Compiler Command Line").
9 | Deleting 2 temporary MEX authorization files.
10 | Removing: 'C:\Users\Andersen\AppData\Local\Temp\b022-660e-5b93-d507_4836.auth'.
11 | Removing: 'C:\Users\Andersen\AppData\Local\Temp\e195-2d04-f447-9530_4836.auth'.
12 | Generating file "G:\碩論備份\20180309\LabelingTool\LabelingTool\for_testing\readme.txt".
13 | Packaging...
14 | Creating the bundle...
15 | Web based installer created at G:\碩論備份\20180309\LabelingTool\LabelingTool\for_redistribution\MyAppInstaller_web.exe.
16 | Packaging complete.
17 | Elapsed packaging time was: 1 minutes and 0 seconds.
18 |
19 |
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/Video_to_Frame.py:
--------------------------------------------------------------------------------
1 | # Program To Read video
2 | # and Extract Frames
3 | import cv2
4 | import time
5 |
6 | # Function to extract frames
7 | def FrameCapture(path):
8 | # Path to video file
9 | vidObj = cv2.VideoCapture(path)
10 |
11 | # Used as counter variable
12 | count = 0
13 | frame_rate = 29.97
14 | prev = 0
15 | # checks whether frames were extracted
16 | success = 1
17 |
18 | while success:
19 | # vidObj object calls read
20 | # function extract frames
21 |
22 | time_elapsed = time.time() - prev
23 | success, image = vidObj.read()
24 |
25 | if time_elapsed > 1. / frame_rate:
26 | prev = time.time()
27 | cv2.imwrite("C:/Users/rswai/Google_Drive/AIML/Projects/TrackNetMirror-master/Data/images/frame_%d.jpg" % count, image)
28 |
29 | count += 1
30 |
31 | # Driver Code
32 | if __name__ == '__main__':
33 | # Calling the function
34 | FrameCapture(r"C:\Users\rswai\Google_Drive\AIML\Projects\TrackNetMirror-master\Data\vids\vid1_1.mp4")
35 |
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_redistribution/MyAppInstaller_web.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/LabelingTool/LabelingTool/for_redistribution/MyAppInstaller_web.exe
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_redistribution_files_only/LabelingTool.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/LabelingTool/LabelingTool/for_redistribution_files_only/LabelingTool.exe
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_redistribution_files_only/default_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/LabelingTool/LabelingTool/for_redistribution_files_only/default_icon.ico
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_redistribution_files_only/readme.txt:
--------------------------------------------------------------------------------
1 | MATLAB Compiler
2 |
3 | 1. Prerequisites for Deployment
4 |
5 | . Verify the MATLAB Runtime is installed and ensure you
6 | have installed version 9.2 (R2017a).
7 |
8 | . If the MATLAB Runtime is not installed, do the following:
9 | (1) enter
10 |
11 | >>mcrinstaller
12 |
13 | at MATLAB prompt. The MCRINSTALLER command displays the
14 | location of the MATLAB Runtime installer.
15 |
16 | (2) run the MATLAB Runtime installer.
17 |
18 | Or download the Windows 64-bit version of the MATLAB Runtime for R2017a
19 | from the MathWorks Web site by navigating to
20 |
21 | http://www.mathworks.com/products/compiler/mcr/index.html
22 |
23 |
24 | For more information about the MATLAB Runtime and the MATLAB Runtime installer, see
25 | Package and Distribute in the MATLAB Compiler documentation
26 | in the MathWorks Documentation Center.
27 |
28 |
29 | NOTE: You will need administrator rights to run MCRInstaller.
30 |
31 |
32 | 2. Files to Deploy and Package
33 |
34 | Files to package for Standalone
35 | ================================
36 | -LabelingTool.exe
37 | -MCRInstaller.exe
38 | -if end users are unable to download the MATLAB Runtime using the above
39 | link, include it when building your component by clicking
40 | the "Runtime downloaded from web" link in the Deployment Tool
41 | -This readme file
42 |
43 | 3. Definitions
44 |
45 | For information on deployment terminology, go to
46 | http://www.mathworks.com/help. Select MATLAB Compiler >
47 | Getting Started > About Application Deployment >
48 | Deployment Product Terms in the MathWorks Documentation
49 | Center.
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_redistribution_files_only/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/LabelingTool/LabelingTool/for_redistribution_files_only/splash.png
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_testing/LabelingTool.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/LabelingTool/LabelingTool/for_testing/LabelingTool.exe
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_testing/mccExcludedFiles.log:
--------------------------------------------------------------------------------
1 | The List of Excluded Files
2 | Excluded files Exclusion Message ID Reason For Exclusion Exclusion Rule
3 |
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_testing/readme.txt:
--------------------------------------------------------------------------------
1 | MATLAB Compiler
2 |
3 | 1. Prerequisites for Deployment
4 |
5 | . Verify the MATLAB Runtime is installed and ensure you
6 | have installed version 9.2 (R2017a).
7 |
8 | . If the MATLAB Runtime is not installed, do the following:
9 | (1) enter
10 |
11 | >>mcrinstaller
12 |
13 | at MATLAB prompt. The MCRINSTALLER command displays the
14 | location of the MATLAB Runtime installer.
15 |
16 | (2) run the MATLAB Runtime installer.
17 |
18 | Or download the Windows 64-bit version of the MATLAB Runtime for R2017a
19 | from the MathWorks Web site by navigating to
20 |
21 | http://www.mathworks.com/products/compiler/mcr/index.html
22 |
23 |
24 | For more information about the MATLAB Runtime and the MATLAB Runtime installer, see
25 | Package and Distribute in the MATLAB Compiler documentation
26 | in the MathWorks Documentation Center.
27 |
28 |
29 | NOTE: You will need administrator rights to run MCRInstaller.
30 |
31 |
32 | 2. Files to Deploy and Package
33 |
34 | Files to package for Standalone
35 | ================================
36 | -LabelingTool.exe
37 | -MCRInstaller.exe
38 | -if end users are unable to download the MATLAB Runtime using the above
39 | link, include it when building your component by clicking
40 | the "Runtime downloaded from web" link in the Deployment Tool
41 | -This readme file
42 |
43 | 3. Definitions
44 |
45 | For information on deployment terminology, go to
46 | http://www.mathworks.com/help. Select MATLAB Compiler >
47 | Getting Started > About Application Deployment >
48 | Deployment Product Terms in the MathWorks Documentation
49 | Center.
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_testing/requiredMCRProducts.txt:
--------------------------------------------------------------------------------
1 | 35000 35010
--------------------------------------------------------------------------------
/LabelingTool/LabelingTool/for_testing/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/LabelingTool/LabelingTool/for_testing/splash.png
--------------------------------------------------------------------------------
/LabelingTool/README.md:
--------------------------------------------------------------------------------
1 | # README for labeling tool
2 |
3 | The excutable file is under directory LabelingTool/for_redistribution_files_only, named LabelingTool.exe
4 |
5 | You need to check if the MATLAB Runtime is installed before you run the program.
6 |
7 | ## How to use it?
8 |
9 | 1. Open the LabelingTool.exe and you will see a window has a main region for image.
10 | 2. Click the "Open" button at up-left corner to open the image source, choose and directory for all images. The image will show in main region in the window.
11 | 3. Move the cursor on the target and click to label it.
12 | 4. The side bar on the right part are the visibility and status of the target:
13 | * Visibility is divided into 4 parts: No Ball, Easy Identification, Hard Identification, Occluded Ball
14 | * Status has three circumstances: Flying, Hit, Bouncing
15 | 5. Using right arrow key and left arrow key on keyborad can move forward and backward image
16 | 6. The text above the main region is noticing user if the image is labeled or not:
17 | * If it is blue, means already labeled
18 | * If it is red, means not label yet
19 | 7. After labeled all images, click the "Output" button at right down corner to output the labeling file. The labeling file will save as csv file, named "Label.csv" under same directory of images.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TrackNet
2 | Heatmap based high speed tiny sport objects tracking based on TrackNet
3 |
4 | 
5 |
6 |
7 | ## Usage
8 |
9 | ### Installation
10 |
11 | ```bash
12 | pip install -r requirements.txt
13 | ```
14 |
15 |
16 | ### Inference
17 |
18 | ```bash
19 | # video file with output
20 | cd Code_Baddy
21 | python predict_video.py --save_weights_path=weights/model_baddy.h5 --input_video_path=path_to_file.mp4 --output_video_path="tracked.mp4" --n_classes=256
22 | ```
23 |
24 | ### Labeling Tool: Make your own dataset
25 | See the readme file in the LabelingTool directory
26 |
27 | ### Training
28 |
29 | 1. Use the TrackNet_Python.ipynb to create heatmap as Ground Truth, and save heatmap as JPG file. (First Cell)
30 |
31 | 2. Create the training and testing csv files (Second cell)
32 | Change the folder path to your custom paths for 1. and 2.
33 | 3. Copy the training.csv and testing.csv file to Code_Baddy/Code_Custom folder
34 | 4. After have training images and ground truth, we can start to train the TrackNet model II (Three frame Input)
35 | * Open command line
36 | * Change directory to Code_Baddy/Code_Custom
37 | * Using following command as example, you may need to change the command:
38 |
39 | ```bash
40 | # Train with custom dataset
41 | python train.py --save_weights_path=weights/model.h5 --training_images_name="training.csv" --epochs=500 --n_classes=256 -- input_height=360 --input_width=640 --load_weights=2 --step_per_epochs=200 --batch_size=2
42 | ```
43 |
44 | * Trained model weight will be save in weights/model.h5
45 |
46 | * Detailed explanation
47 | --save_weights_path: Save the weight path
48 | --training_images_name: Training images csv file path, training.csv
49 | --epochs: Epochs be set as 500 in this work
50 | --n_classes: Last layer classes, since the output value of TrackNet is between 0-255, the last layer depth be set as 256
51 | --input_height: Input height be resize as 360 in this work
52 | --input_width: Input width be resize as 640 in this work
53 | --load_weights: If you want to retrain the weights from previous weight, give the number of weight in weights/model. If not, delete it.
54 | --step_per_epochs: Step per Epochs be set as 200 in this work
55 | -batch_size: Batch size be set as 2 in this work
56 |
57 | ## References
58 |
59 | GitHub : [TrackNet](https://nol.cs.nctu.edu.tw:234/open-source/TrackNet/tree/master)
60 |
61 | Paper : [TrackNet: A Deep Learning Network for Tracking High-speed and Tiny Objects in Sports Applications](https://ieeexplore.ieee.org/abstract/document/8909871/authors#authors)
62 |
--------------------------------------------------------------------------------
/Resources/README.md:
--------------------------------------------------------------------------------
1 | # TrackNet: Tennis Ball Tracking from Broadcast Video by Deep Learning Networks
2 |
3 | ## First, you have to install cuda, cudnn and tensorflow, tutorial:
4 | https://medium.com/@zhanwenchen/install-cuda-and-cudnn-for-tensorflow-gpu-on-ubuntu-79306e4ac04e
5 |
6 | ## Second, install some python library with pip:
7 | * sudo pip install numpy
8 | * sudo pip install matplotlib
9 | * sudo pip install pillow
10 | * sudo pip install keras
11 | * sudo pip install opencv-python
12 | * sudo pip install pydot
13 | * sudo pip install h5py
14 | * sudo apt-get install graphviz
15 |
16 |
17 |
18 | ## How to train a new TrackNet I weight?
19 | 1. Create heatmap as Ground Truth, and save heatmap as JPG file
20 | Code be save in TrackNet_Python.ipynb (first part), you may need to change the folder path in python code
21 | 2. The training file name and testing file name of TrackNet must be output as csv file
22 | Code be save in TrackNet_Python.ipynb (second part), you also need to change the folder path in code
23 | 3. Copy the training_model1.csv file and testing_model1.csv file to TrackNet_One_Frames_Input folder
24 | 4. After have training images and ground truth, we can start to train the TrackNet model I
25 | * Open command line
26 | * Change directory to TrackNet_One_Frames_Input folder
27 | * Using following command as example, you may need to change the command:
28 |
29 | > python train.py --save_weights_path=weights/model --training_images_name="training_model1.csv" --epochs=500 --n_classes=256 --input_height=360 --input_width=640 --load_weights=1 --step_per_epochs=200 --batch_size=2
30 | * Trained model weight will be save in weights/model.0
31 |
32 | * Detailed explanation
33 | --save_weights_path: Save the weight path
34 | --training_images_name: Training images csv file path, training_model1.csv
35 | --epochs: Epochs be set as 500 in this work
36 | --n_classes: Last layer classes, since the output value of TrackNet is between 0-255, the last layer depth be set as 256
37 | --input_height: Input height be resize as 360 in this work
38 | --input_width: Input width be resize as 640 in this work
39 | --load_weights: If you want to retrain the weights from previous weight, give the number of weight in weights/model. If not, delete it.
40 | --step_per_epochs: Step per Epochs be set as 200 in this work
41 | -batch_size: Batch size be set as 2 in this work
42 |
43 |
44 | ## How to train a new TrackNet II weight?
45 | 1. Create heatmap as Ground Truth, and save heatmap as JPG file
46 | Code be saved in TrackNet_Python.ipynb (first part), you may need to change the folder path in python code
47 | 2. The training file name and testing file name of TrackNet must be output as csv file
48 | Code be save in TrackNet_Python.ipynb (third part), you also need to change the folder path in code
49 | 3. Copy the training_model2.csv file and testing_model2.csv file to TrackNet_Three_Frames_Input folder
50 | 4. After have training images and ground truth, we can start to train the TrackNet model II
51 | * Open command line
52 | * Change directory to TrackNet_Three_Frames_Input folder
53 | * Using following command as example, you may need to change the command:
54 |
55 | > python train.py --save_weights_path=weights/model --training_images_name="training_model2.csv" --epochs=500 --n_classes=256 --input_height=360 --input_width=640 --load_weights=2 --step_per_epochs=200 --batch_size=2
56 | * Trained model weight will be save in weights/model.0
57 |
58 | * Detailed explanation
59 | --save_weights_path: Save the weight path
60 | --training_images_name: Training images csv file path, training_model2.csv
61 | --epochs: Epochs be set as 500 in this work
62 | --n_classes: Last layer classes, since the output value of TrackNet is between 0-255, the last layer depth be set as 256
63 | --input_height: Input height be resize as 360 in this work
64 | --input_width: Input width be resize as 640 in this work
65 | --load_weights: If you want to retrain the weights from previous weight, give the number of weight in weights/model. If not, delete it.
66 | --step_per_epochs: Step per Epochs be set as 200 in this work
67 | -batch_size: Batch size be set as 2 in this work
68 |
69 | ## How to train a new TrackNet II' weight?
70 | 1. Create heatmap as Ground Truth, and save heatmap as JPG file
71 | Code be save in TrackNet_Python.ipynb (first part), you may need to change the folder path in python code
72 | 2. The training file name and testing file name of TrackNet must be output as csv file
73 | Code be save in TrackNet_Python.ipynb (third part, fourth part amd fifth part), you also need to change the folder path in code
74 | 3. Copy the training_model3.csv file to TrackNet_Three_Frames_Input folder
75 | 4. After have training images and ground truth, we can start to train the TrackNet model II'
76 | * Open command line
77 | * Change directory to TrackNet_Three_Frames_Input folder
78 | * Using following command as example, you may need to change the command:
79 |
80 | > python train.py --save_weights_path=weights/model --training_images_name="training_model3.csv" --epochs=500 --n_classes=256 --input_height=360 --input_width=640 --load_weights=2 --step_per_epochs=200 --batch_size=2
81 | * Trained model weight will be save in weights/model.0
82 |
83 | * Detailed explanation
84 | --save_weights_path: Save the weight path
85 | --training_images_name: Training images csv file path, training_model3.csv
86 | --epochs: Epochs be set as 500 in this work
87 | --n_classes: Last layer classes, since the output value of TrackNet is between 0-255, the last layer depth be set as 256
88 | --input_height: Input height be resize as 360 in this work
89 | --input_width: Input width be resize as 640 in this work
90 | --load_weights: If you want to retrain the weights from previous weight, give the number of weight in weights/model. If not, delete it.
91 | --step_per_epochs: Step per Epochs be set as 200 in this work
92 | -batch_size: Batch size be set as 2 in this work
93 |
94 | ## How to output all of heatmap predictions?
95 | 1. Open command line
96 | 2. Change directory to TrackNet folder (TrackNet_Three_Frames_Input or TrackNet_One_Frames_Input)
97 | 3. Using following command as example, you may need to change the command:
98 |
99 | python predict.py --save_weights_path=weights/model.2 --test_images="/media/andersen/D/Thesis/Dataset/Clip" --output_path="/media/andersen/D/Thesis/Prediction/Model2/Clip" --n_classes=256 --input_height=360 --input_width=640 --output_height=720 --output_width=1280
100 |
101 | * Detailed explanation
102 | --save_weights_path: which model weight need to be loaded
103 | --test_images: testing images path
104 | --output_path: output heatmap path
105 | --n_classes: in this work depth be set as 256
106 | --input_height: Input height be resize as 360 in this work
107 | --input_width: Input width be resize as 360 in this work
108 | --output_height: resize the heatmap height, output height be set as 720 in this work
109 | -output_width: resize the heatmap width,output width be set as 1280 in this work
110 |
111 |
112 |
113 | ## How to use TrackNet predict video?
114 | 1. Open command line
115 | 2. Change directory to TrackNet folder (TrackNet_Three_Frames_Input or TrackNet_One_Frames_Input)
116 | 3. using following command as example, you may need to change the command:
117 |
118 | python predict_video.py --save_weights_path=weights/model.3 --input_video_path="/media/andersen/D/Test/Clip1.mp4" --output_video_path="/media/andersen/D/Test/Clip1_TrackNet.mp4" --n_classes=256
119 |
120 | * Detailed explanation
121 | --save_weights_path: which model weight need to be loaded
122 | --input_video_path: Input video path
123 | --output_video_path: Output video path, if not, the video will be save in the same path of input video
124 | --n_classes: In this work depth be set as 256
125 |
126 |
127 |
128 | ## TrackNet trained weights:
129 | * TrackNet model I >> TrackNet_One_Frames_Input/weights.model.1
130 | * TrackNet model II >> TrackNet_Three_Frames_Input/weights.model.2
131 | * TrackNet model II' >> TrackNet_Three_Frames_Input/weights.model.3
132 |
133 |
134 |
135 | ## Labeling Tool: Make your own dataset
136 | See the readme file in the LabelingTool directory
--------------------------------------------------------------------------------
/Resources/TrackNet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/Resources/TrackNet.pdf
--------------------------------------------------------------------------------
/Resources/TrackNet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/Resources/TrackNet.png
--------------------------------------------------------------------------------
/Resources/coachAI.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/Resources/coachAI.pdf
--------------------------------------------------------------------------------
/TrackNet.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weekenddeeplearning/TrackNet/2836c388234fce6dfc967f8c694d0970928258ea/TrackNet.gif
--------------------------------------------------------------------------------
/Utils/frame_to_vid.py:
--------------------------------------------------------------------------------
1 | import cv2
2 | import os
3 |
4 | image_folder = r'C:\Users\rswai\Google_Drive\AIML\Projects\TrackNetMirror-master\Data\Tennis\game10\Clip12'
5 | video_name = 'output.mp4'
6 |
7 | images = [img for img in os.listdir(image_folder) if img.endswith(".jpg")]
8 | frame = cv2.imread(os.path.join(image_folder, images[0]))
9 | height, width, layers = frame.shape
10 |
11 | # fourcc = cv2.cv.CV_FOURCC('MP4V')
12 | fourcc = cv2.VideoWriter_fourcc(*'mp4v')
13 |
14 | video = cv2.VideoWriter(video_name, fourcc, 30, (width,height))
15 |
16 | for image in images:
17 | video.write(cv2.imread(os.path.join(image_folder, image)))
18 |
19 | cv2.destroyAllWindows()
20 | video.release()
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | argparse
2 | numpy
3 | matplotlib
4 | pillow
5 | h5py
6 | pydot
7 | keras
8 | tensorflow-gpu
9 | opencv-python
10 |
--------------------------------------------------------------------------------