EgoVideoStabilizer  1.0.0
file_operations.cpp File Reference

Functions to manipulate files. More...

Include dependency graph for file_operations.cpp:

Functions

std::vector< int > loadMasterFramesFromFile (const EXPERIMENT &experiment_settings)
 Function to load the master frames from a file defined in the field read_masterframes_filename in the experiment_settings. More...
 
bool saveMasterFramesToFile (const EXPERIMENT &experiment_settings, const std::vector< int > masters_frames)
 Function to save the calculated master frames into a file defined in the field save_masterframes_filename in the experiment_settings. More...
 
void readSelectedFramesCSV (std::string filename, std::vector< int > &selected_frames)
 Function to read a CSV composed by frames selected by the selection algorithm. More...
 
std::string getExperimentId ()
 Function that manages the experiments ID automatically. More...
 
std::istream & goToLine (std::istream &file, const unsigned int line)
 Function that set the file pointer to the desired line, if it is smaller than the file number of lines. More...
 
double getSemanticCost (const EXPERIMENT &experiment_settings, const int frame_src, const int frame_dst)
 Function that returns the semantic cost of the transition from the frame_src to the frame_dst. More...
 
std::vector< std::vector< double > > loadInstabilityCostsFromFile (const EXPERIMENT &experiment_settings)
 loadInstabilityCostsFromFile Loads the instability costs from a CSV file (matrix format). More...
 
std::vector< std::vector< double > > loadOpticalFlow (const EXPERIMENT &experiment_settings)
 loadOpticalFlow Loads the Optical Flow calculated by the FlowNet from a CSV file. More...
 
bool str2bool (std::string str)
 str2bool convert a string to boolean. More...
 
std::string filter_string (std::string str)
 filter_string filter a string to remove white spaces and line break. More...
 

Detailed Description

Functions to manipulate files.

Functions to read from TXT and CSV files, write data on files.

Function Documentation

std::string filter_string ( std::string  str)

filter_string filter a string to remove white spaces and line break.

Parameters
string
Returns
string
Author
Felipe Cadar Chamone
Date
14/07/2017
std::string getExperimentId ( )

Function that manages the experiments ID automatically.

Returns
std::string - The experiment id formatted by 4 digits
Author
Washington Luis de Souza Ramos
Date
19/04/2016
double getSemanticCost ( const EXPERIMENT experiment_settings,
const int  frame_src,
const int  frame_dst 
)

Function that returns the semantic cost of the transition from the frame_src to the frame_dst.

Function that returns the semantic cost of the transiction from the frame_src to the frame_dst.

The file where the semantic cost will be find is defined in the experiment_settings

Parameters
experiment_settings- variable with the experiment setting.
frame_src- first frame of the transition.
frame_dst- last frame of the transition.
Returns
double - The semantic cost of the transiction of the frame_src to the frame_dst. Returns the complementary value ( 1 - x ).
Author
Michel Melo da Silva
Date
30/04/2016
std::istream& goToLine ( std::istream &  file,
const unsigned int  line 
)

Function that set the file pointer to the desired line, if it is smaller than the file number of lines.

Parameters
file- std::ifstream object where the file is read.
line- line where the header read will be set.
Returns
std::istream - Reference to the file in the selected line.
Author
Michel Melo da Silva
Date
30/04/2016
std::vector< std::vector<double> > loadInstabilityCostsFromFile ( const EXPERIMENT experiment_settings)

loadInstabilityCostsFromFile Loads the instability costs from a CSV file (matrix format).

Parameters
experiment_settings
Returns
The matrix of instability costs
Author
Washington Luis de Souza Ramos
Date
12/09/2016
std::vector<int> loadMasterFramesFromFile ( const EXPERIMENT experiment_settings)

Function to load the master frames from a file defined in the field read_masterframes_filename in the experiment_settings.

Parameters
experiment_settings- variable with the experiment setting.
Returns
std::vector - vector of master frames loaded from file describle in the experiment settings.
Author
Michel Melo da Silva
Date
08/04/2016
std::vector< std::vector<double> > loadOpticalFlow ( const EXPERIMENT experiment_settings)

loadOpticalFlow Loads the Optical Flow calculated by the FlowNet from a CSV file.

Parameters
experiment_settings
Returns
Vector[j][i] with the optical flow from the image j to j+1 (i=0 is dx and i=1 is dy).
Author
Michel Melo da Silva
Date
09/01/2017
void readSelectedFramesCSV ( std::string  filename,
std::vector< int > &  selected_frames 
)

Function to read a CSV composed by frames selected by the selection algorithm.

Parameters
filename- std::string with the filename of the CSV file that contains the selected frames of the reduced video.
selected_frames- vector to save the selected frames.
Returns
void
Author
Washington Luis de Souza Ramos
Date
14/04/2016
bool saveMasterFramesToFile ( const EXPERIMENT experiment_settings,
const std::vector< int >  masters_frames 
)

Function to save the calculated master frames into a file defined in the field save_masterframes_filename in the experiment_settings.

Parameters
experiment_settings- variable with the experiment setting.
masters_frames- vector of master frames to be saved in file describle in the experiment settings.
Returns
bool true - if the writer return sucess while writing the file.
bool false - if the writer return fail while writing the file.
Author
Michel Melo da Silva
Date
08/04/2016
bool str2bool ( std::string  str)

str2bool convert a string to boolean.

Parameters
string
Returns
boolean
Author
Felipe Cadar Chamone
Date
14/07/2017