marsvision.utilities.DataUtility module¶
-
class
marsvision.utilities.DataUtility.
DataUtility
(in_path: Optional[str] = None, out_path: Optional[str] = None)¶ Bases:
object
-
__init__
(in_path: Optional[str] = None, out_path: Optional[str] = None)¶ This class is responsible for loading images from an input directory, extracting features from them, and outputting the processed data as a .csv file.
A class parameter can be used to classify all images within the input folder.
It can be invoked directly via the command line.
—
Parameters:
in_path (str): Optional. The input directory which contains images to be read. Reads from the current working directory if left empty.
out_path (str): Optional. The output directory to which the csv will be written. Writes to current working directory if left empty.
detector_name(string): Optional. Name of the detector to use to detect keypoints.
—
Command Line Arguments:
–i: Input directory. Default: current working directory
–o: Output directory. Default: output to current working directory.
–c: Class for input files. Default: use containing folder as class name.
–f: Boolean, whether to include the file name or not. Default: True
-
data_reader
()¶ Walk through a folder and load images, file names, and folder names into memory as member variables.
All .jpg images in the working directory, and all subdirectories are loaded.
This function updates the self.images, self.file_names, and self.labels members with the loaded data.
-
data_transformer
()¶ Use the FeatureExtractor module to load a vector of features into memory as a member variable.
Creates a Pandas dataframe from the extracted features, and write the data to a .csv file (“output.csv”), to the path which was specified in the constructor.
Set columns depending on user preferences: If a class is defined, write to the class to a class column. If no class is defines, the containing folder name will be used as the class in the class column. If file names are desired, file names are written to a file_name column.
-
data_writer
()¶ Write the constructed dataframe to an output file (“output.csv”)
-
run
()¶ When called, run() will execute the data_reader(), data_transformer(), and data_writer() functions in order.
The result will be an output .csv file either in the directory from which the script is run, or in the user specified directory.
-