DarkHelp  v1.9.2-1
C++ API for the neural network framework Darknet
Looking for a C++ dev who knows OpenCV?
I'm looking for work. Hire me!
resize_corners.cpp File Reference
#include <filesystem>
#include <fstream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <opencv2/opencv.hpp>
Include dependency graph for resize_corners.cpp:

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[])
 
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...
 

Detailed Description

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.

Function Documentation

◆ find_all_images()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lowercase()

std::string lowercase ( const std::string &  raw)

Referenced by find_all_images(), and parse_names_file().

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

References find_all_images(), parse_names_file(), and process_images().

Here is the call graph for this function:

◆ parse_names_file()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_images()

void process_images ( )

Loop through all of the images and resize the corner annotations.

References annotated_image_filenames, corner_size, and corners.

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

◆ annotated_image_filenames

std::vector<std::string> annotated_image_filenames

These are all of the images with annotations that we need to process.

See also
find_all_images()

Referenced by find_all_images(), and process_images().

◆ corner_size

const int corner_size = 16

Size to use for corner rectangles.

Referenced by process_images().

◆ corners

std::map<int, std::string> corners

Annotation indexes, such as 0 -> "tl", 1 -> "tr", ...

Referenced by parse_names_file(), and process_images().

◆ indexes

std::map<std::string, int> indexes

Annotation indexes, such as "tl" -> 0, "tr" -> 1, ...

Referenced by parse_names_file().