EgoVideoStabilizer  1.0.0
experiments.h
Go to the documentation of this file.
1 //
4 // SemanticFastForward_EPIC@ECCVW is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // SemanticFastForward_JVCI is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with SemanticFastForward_EPIC@ECCVW. If not, see <http://www.gnu.org/licenses/>.
16 //
18 
26 #ifndef EXPERIMENTS_H
27 #define EXPERIMENTS_H
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <algorithm>
32 #include <string.h>
33 #include <unistd.h>
34 
35 #include <opencv2/core/core.hpp>
36 
38 
40 
42 
43 EXPERIMENT load_experiments_settings ( std::string settingsFilename ){
45 
46 
47  std::string video_path;
48  std::string output_path;
49  std::string video_name;
50  std::string original_video_filename;
51  std::string read_masterframes_filename;
52  std::string selected_frames_filename;
53  std::string semantic_costs_filename;
54  std::string instability_costs_filename;
55  std::string optical_flow_filename;
56  int segmentSize = 0;
57  bool saveMasterFramesInDisk = false;
58  bool saveVideoInDisk = false;
59  bool runningParallel = true;
61  cv::FileStorage fs(settingsFilename, cv::FileStorage::READ);
62 
63  if (!fs.isOpened()){
64  return experiment_settings;
65  }
66 
67  video_path = filter_string(fs["video_path"]);
68  video_name = filter_string(fs["video_name"]);
69  output_path = filter_string(fs["output_path"]);
70  original_video_filename = filter_string(fs["original_video_filename"]);
71  selected_frames_filename = filter_string(fs["selected_frames_filename"]);
72  read_masterframes_filename = filter_string(fs["read_masterframes_filename"]);
73  semantic_costs_filename = filter_string(fs["semantic_costs_filename"]);
74 
75  segmentSize = fs["segmentSize"];
76 
77  runningParallel = str2bool(fs["runningParallel"]);
78  saveMasterFramesInDisk = str2bool(fs["saveMasterFramesInDisk"]);
79  saveVideoInDisk = str2bool(fs["saveVideoInDisk"]);
80 
81 
82  char hostname[HOST_NAME_MAX];
83  gethostname(hostname, HOST_NAME_MAX);
84 
85  experiment_settings.id = getExperimentId();
86  experiment_settings.video_filename = video_path + "/" + video_name;
87  experiment_settings.output_path = SSTR ( output_path << "/" << video_name.substr(0,video_name.find_last_of('.')) << "_N" << segmentSize << "_"
88  << hostname << "_ExpID_" << experiment_settings.id);
89  experiment_settings.save_video_filename = SSTR ( experiment_settings.output_path << "/StabilizedVideo_" << video_name.substr(0,video_name.find_last_of('.')) << "_N"
90  << segmentSize << "_" << hostname << "_ExpID_" << experiment_settings.id << ".avi" );
91  experiment_settings.save_master_frames_filename = SSTR ( experiment_settings.output_path << "/MasterFrames_N" << segmentSize << "_"
92  << video_name.substr(0,video_name.find_last_of('.')) << ".csv");
93  experiment_settings.log_file_name = SSTR ( experiment_settings.output_path << "/Log_" << video_name.substr(0,video_name.find_last_of('.')) << "_N"
94  << segmentSize << "_" << hostname << "_ExpID_" << experiment_settings.id << ".txt" ) ;
95  experiment_settings.read_master_frames_filename = read_masterframes_filename;
96  experiment_settings.save_master_frames_in_disk = saveMasterFramesInDisk;
97  experiment_settings.save_video_in_disk = saveVideoInDisk;
98  experiment_settings.semantic_costs_filename = semantic_costs_filename;
99  experiment_settings.instability_costs_filename = instability_costs_filename;
100  experiment_settings.selected_frames_filename = selected_frames_filename;
101  experiment_settings.original_video_filename = original_video_filename;
102  experiment_settings.segment_size = segmentSize;
103  experiment_settings.running_parallel = runningParallel;
104  experiment_settings.optical_flow_filename = optical_flow_filename;
105 
106  return experiment_settings;
107 }
108 
109 #endif // EXPERIMENTS_H
std::string original_video_filename
Complete path to the folder where the results will be saved.
Definition: experiment_struct.h:36
int segment_size
Complete path and filename to save the txt file log execution.
Definition: experiment_struct.h:45
std::string video_filename
Definition: experiment_struct.h:34
bool running_parallel
Save stabilized video in Disk.
Definition: experiment_struct.h:48
std::string semantic_costs_filename
Complete path and filename of the csv file with the selected master frames that was selected to creat...
Definition: experiment_struct.h:41
std::string read_master_frames_filename
Complete path and filename of the original video.
Definition: experiment_struct.h:37
Fields declaration of the experiment settings.
EXPERIMENT load_experiments_settings(std::string settingsFilename)
Definition: experiments.h:43
Header functions for the file_operations.cpp.
EXPERIMENT experiment_settings
Definition: main.cpp:59
std::string save_video_filename
Complete path and filename to save the txt file with the selected master frames.
Definition: experiment_struct.h:39
std::string optical_flow_filename
Complete path and filename of the csv file with the jitter costs of the transitions.
Definition: experiment_struct.h:43
std::string instability_costs_filename
Complete path and filename of the csv file with the semantic costs of the frame transitions.
Definition: experiment_struct.h:42
std::string filter_string(std::string str)
filter_string filter a string to remove white spaces and line break.
Definition: file_operations.cpp:352
std::string id
Definition: experiment_struct.h:33
std::string selected_frames_filename
Complete path and filename of the save the stabilized video.
Definition: experiment_struct.h:40
bool save_video_in_disk
After calculte the master frames, do you want to save it in a file? After you can load it directly wi...
Definition: experiment_struct.h:47
std::string log_file_name
Complete path and filename of the csv file with the optical flow calculated by the FlowNet...
Definition: experiment_struct.h:44
bool save_master_frames_in_disk
Size of the segments where the master frames will be calculated.
Definition: experiment_struct.h:46
Definition: experiment_struct.h:32
std::string getExperimentId()
Function that manages the experiments ID automatically.
Definition: file_operations.cpp:141
bool str2bool(std::string str)
str2bool convert a string to boolean.
Definition: file_operations.cpp:334
Macro with specific codes.
std::string output_path
Complete path and filename of the video with extension.
Definition: experiment_struct.h:35
#define SSTR(x)
Definition: execute_commands.h:101
std::string save_master_frames_filename
Complete path and filename of the txt file with the selected master frames.
Definition: experiment_struct.h:38