#include <filesystem>
#include <fstream>
#include <map>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <opencv2/opencv.hpp>
Functions | |
void | find_all_images (const std::filesystem::path &root_directory) |
Perform a recursive directory search to find all the images. More... | |
std::string | lowercase (const std::string &raw) |
int | main (int argc, char *argv[]) |
cv::Size | network_dimensions (-1, -1) |
The size of the network will be parsed from the width=... and height=... lines in the .cfg file. More... | |
void | parse_cfg_file (const std::filesystem::path &cfg_file) |
Find the width=... and height=... values from the .cfg file. More... | |
void | parse_names_file (const std::filesystem::path &names_file) |
Read the .names file and find all of the corner indexes we need to resize. More... | |
void | process_images () |
Loop through all of the images and resize the corner annotations. More... | |
Variables | |
std::vector< std::string > | annotated_image_filenames |
These are all of the images with annotations that we need to process. More... | |
const int | corner_size = 16 |
Size to use for corner rectangles. More... | |
std::map< int, std::string > | corners |
Annotation indexes, such as 0 -> "tl", 1 -> "tr", ... More... | |
std::map< std::string, int > | indexes |
Annotation indexes, such as "tl" -> 0, "tr" -> 1, ... More... | |
This simple tool looks for classes named "TL", "TR", "BL", and "BR". This is typically used to indicate the corners of objects, where "TL" is "top-left", "BR is "bottom-right", etc. If it finds any of these classes, the tool will then read through all of the existing annotations, resize the corners to a specific size, and re-write the annotation files with the new sizes.
void find_all_images | ( | const std::filesystem::path & | root_directory | ) |
Perform a recursive directory search to find all the images.
Then we exclude anything in DarkMark's image cache or which doesn't have an annotation file. Results are stored in the global variable annotated_image_filenames.
References annotated_image_filenames, and lowercase().
Referenced by main().
std::string lowercase | ( | const std::string & | raw | ) |
Referenced by find_all_images(), parse_cfg_file(), and parse_names_file().
int main | ( | int | argc, |
char * | argv[] | ||
) |
References find_all_images(), parse_cfg_file(), parse_names_file(), and process_images().
cv::Size network_dimensions | ( | - | 1, |
- | 1 | ||
) |
The size of the network will be parsed from the width=... and height=... lines in the .cfg file.
Referenced by DarkHelp::NN::init(), DarkHelp::NN::is_initialized(), DarkHelp::NN::network_size(), parse_cfg_file(), DarkHelp::NN::predict_internal_darknet(), DarkHelp::NN::predict_internal_opencv(), DarkHelp::NN::predict_tile(), process_images(), and DarkHelp::NN::reset().
void parse_cfg_file | ( | const std::filesystem::path & | cfg_file | ) |
Find the width=... and height=... values from the .cfg file.
References lowercase(), and network_dimensions().
Referenced by main().
void parse_names_file | ( | const std::filesystem::path & | names_file | ) |
Read the .names file and find all of the corner indexes we need to resize.
These classes will have names such as TL
, TR
, BR
, and BL
. The search for names is case-insensitive.
References corners, indexes, and lowercase().
Referenced by main().
void process_images | ( | ) |
Loop through all of the images and resize the corner annotations.
References annotated_image_filenames, corner_size, corners, and network_dimensions().
Referenced by main().
std::vector<std::string> annotated_image_filenames |
These are all of the images with annotations that we need to process.
Referenced by find_all_images(), and process_images().
const int corner_size = 16 |
Size to use for corner rectangles.
This size is in pixels AFTER the image has been resized to the neural network dimensions! But the only way to do this is to parse the .cfg file for the width and height of the network.
Referenced by process_images().
std::map<int, std::string> corners |
Annotation indexes, such as 0 -> "tl", 1 -> "tr", ...
Referenced by parse_names_file(), and process_images().
std::map<std::string, int> indexes |
Annotation indexes, such as "tl" -> 0, "tr" -> 1, ...
Referenced by parse_names_file().