Skip to content

Commit

Permalink
main: Fixed bug when saving features after correcting ID flips
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltaylor committed Dec 13, 2023
1 parent a7a5d02 commit ffeb508
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
24 changes: 24 additions & 0 deletions tracking/determine_whether_to_recompute_feature_type.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function [do_recompute, output_folder_path] = ...
determine_whether_to_recompute_feature_type(feature_type_string, folder_name_template, parent_folder_path)
% Try to find a folder matching folder_name_template within
% parent_folder_path. On return, do_recompute is true iff exactly one such
% folder can be found, and output_folder_path is the path to that folder. If
% more than one match is found, issue a warning stating as much (using
% feature_type_string in the warning message to indicate which feature type is
% problematic). Used to determine whether to recompute JAABA/CSV features
% after indentity corrections are done in the visualizer.
folder_names_matching_JAABA = folder_names_matching_template(parent_folder_path, folder_name_template) ;
if length(folder_names_matching_JAABA) == 0 , %#ok<ISMT>
do_recompute = false ;
output_folder_path = [] ;
elseif length(folder_names_matching_JAABA) == 1 ,
do_recompute = true ;
output_folder_path = fullfile(parent_folder_path, folder_names_matching_JAABA{1}) ;
else
% Should we issue a warning here?
warning('Not saving %s features b/c more than one folder matching "%s" template in %s', ...
feature_type_string, folder_name_template, parent_folder_path) ;
do_recompute = false ;
output_folder_path = [] ;
end
end
9 changes: 9 additions & 0 deletions tracking/tracker_job_features.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function tracker_job_features(output_feature_file_path, output_jaaba_folder_path, output_features_csv_folder_path, ...
input_video_file_name, input_tracking_file_name, calibration_file_name, ...
options)
% Recompute the features file, csv feature files, and jaaba features.
calibration = load_anonymous(calibration_file_name) ;
core_tracker_compute_features(output_feature_file_path, output_features_csv_folder_path, output_jaaba_folder_path, ...
input_video_file_name, input_tracking_file_name, calibration, ...
options) ;
end
7 changes: 7 additions & 0 deletions tracking/utilities/folder_names_matching_template.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function result = folder_names_matching_template(parent_folder_name, template)
% Return folder names matching the template within parent_folder_name
s_from_file_index = dir(fullfile(parent_folder_name, template)) ;
name_from_file_index = { s_from_file_index.name } ;
is_folder_from_file_index = [ s_from_file_index.isdir ] ;
result = name_from_file_index(is_folder_from_file_index) ;
end
3 changes: 3 additions & 0 deletions tracking/utilities/nop.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function nop()
% do nothing
end
21 changes: 11 additions & 10 deletions visualizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -2760,16 +2760,17 @@ function switchSortBy(hObj,~)
f_vid = fullfile(vinfo.filename);
f_res = fullfile(files.path,files.trk);
f_calib = fullfile(files.video_dir,'calibration.mat');
options.save_JAABA = 0;
tmp = dir(fullfile(files.path,'*JAABA'));
if numel(tmp) > 0
options.save_JAABA = 1;
end
tmp = dir(fullfile(files.path,'*trackfeat*'));
options.save_xls = numel(tmp) > 0;
% recompute features and jaaba
recompute = 1;
tracker_job_features(f_vid, f_res, f_calib, options, recompute); % TODO: replace with core_tracker_compute_features() wrapper
output_feature_file_path = fullfile(files.path, files.feat) ;
% Determine whether to recompute the JAABA features, and where to save them
[options.save_JAABA, output_jaaba_folder_path] = ...
determine_whether_to_recompute_feature_type('JAABA', '*JAABA', files.path) ;
% Determine whether to recompute the JAABA features, and where to save them
[options.save_xls, output_features_csv_folder_path] = ...
determine_whether_to_recompute_feature_type('.csv', '*trackfeat*', files.path) ;
% Recompute features, jaaba, and csv
tracker_job_features(output_feature_file_path, output_jaaba_folder_path, output_features_csv_folder_path, ...
f_vid, f_res, f_calib, ...
options) ;
% load the new features
D = load(fullfile(files.path,files.feat)); feat = D.feat;
delete(h)
Expand Down

0 comments on commit ffeb508

Please sign in to comment.