4#include <opencv2/opencv.hpp>
8typedef std::vector <cv::Point>
object;
16std::filesystem::path
createDirectory(
const std::filesystem::path& folder_path,
const std::string& directory_name);
18void globFiles(
const std::string& directory,
const std::string& pattern, std::vector<std::string>& file_paths);
20void readImages(
const std::vector<std::string>& img_paths, std::vector<cv::Mat>& images,
int flags = cv::IMREAD_UNCHANGED);
22cv::Mat
rotate90(cv::Mat img,
int step);
24void processYoloLabels(
const std::string& filePath,
const cv::Mat& img, std::vector<cv::Rect>& yolo_boxes);
26cv::Rect
Yolo2BRect(
const cv::Mat& img,
double x_center,
double y_center,
double width,
double height);
28bool isRoiInImage(
const cv::Rect& roi,
int width=4800,
int height=2703);
30std::vector<cv::Rect>
readYoloBoxes(
const std::filesystem::path& file_path,
const cv::Mat& img);
32std::ofstream
openFile(
const std::string& filename);
34std::vector<cv::Rect>
generateRoisFromPoints(
const std::vector<cv::Point>& points,
const std::vector<cv::Size>& roi_sizes);
38void reshape2sameDim(std::vector<cv::Mat>& clustered_imgs_by_intensity,
const cv::Size& avg_dim);
42void listDirectories(
const std::filesystem::path& directory_path, std::vector<std::string>& final_paths);
44void imshow(
const std::string& win_name, cv::InputArray arr,
bool wait =
true,
float scale = 1.0);
bool isRoiInImage(const cv::Rect &roi, int width=4800, int height=2703)
Checks if a region of interest (ROI) is completely within the image boundaries.
Definition utils.cpp:270
void listDirectories(const std::filesystem::path &directory_path, std::vector< std::string > &final_paths)
Recursively lists all leaf directories within a specified directory.
Definition utils.cpp:544
cv::Rect Yolo2BRect(const cv::Mat &img, double x_center, double y_center, double width, double height)
Converts YOLO format bounding box coordinates to a cv::Rect.
Definition utils.cpp:236
int bitdepth(int ocv_depth)
Definition utils.cpp:592
std::filesystem::path createDirectory(const std::filesystem::path &folder_path, const std::string &directory_name)
Creates a new directory if it does not already exist.
Definition utils.cpp:112
double degrees2rad(double degrees)
Converts degrees to radians.
Definition utils.cpp:15
void reshape2sameDim(std::vector< cv::Mat > &clustered_imgs_by_intensity, const cv::Size &avg_dim)
Resizes a vector of images to the same dimensions.
Definition utils.cpp:457
cv::Mat rotate90(cv::Mat img, int step)
Rotates an image by multiples of 90 degrees clockwise.
Definition utils.cpp:65
std::vector< cv::Point > filterPointsByMinDistance(std::vector< cv::Point > &points, double min_distance)
Filters a set of points by a minimum distance criterion.
Definition utils.cpp:496
void processYoloLabels(const std::string &filePath, const cv::Mat &img, std::vector< cv::Rect > &yolo_boxes)
Processes YOLO labels from a file and converts them to bounding boxes.
Definition utils.cpp:181
void readImages(const std::vector< std::string > &img_paths, std::vector< cv::Mat > &images, int flags=cv::IMREAD_UNCHANGED)
Reads images from a list of file paths and stores them in a vector.
Definition utils.cpp:153
double rad2degrees(double radians)
Converts radians to degrees.
Definition utils.cpp:28
cv::Size calculateAvgDims(const std::filesystem::path &directory_path)
Calculates the average dimensions of all images in a specified directory.
Definition utils.cpp:409
bool sortByDescendingArea(const object &first, const object &second)
Comparator function to sort contours by descending area.
Definition utils.cpp:44
void globFiles(const std::string &directory, const std::string &pattern, std::vector< std::string > &file_paths)
Retrieves a list of file paths that match a specified pattern in a directory.
Definition utils.cpp:134
std::ofstream openFile(const std::string &filename)
Opens a file for writing and returns the output file stream.
Definition utils.cpp:345
std::vector< cv::Rect > readYoloBoxes(const std::filesystem::path &file_path, const cv::Mat &img)
Reads YOLO bounding boxes from a file and converts them to OpenCV cv::Rect format.
Definition utils.cpp:296
std::vector< cv::Rect > generateRoisFromPoints(const std::vector< cv::Point > &points, const std::vector< cv::Size > &roi_sizes)
Generates regions of interest (ROIs) from a set of points and ROI sizes.
Definition utils.cpp:371
std::vector< cv::Point > object
Definition utils.h:8
void imshow(const std::string &win_name, cv::InputArray arr, bool wait=true, float scale=1.0)
Definition utils.cpp:573