72 lines
2.3 KiB
C++
72 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <filesystem>
|
|
#include <opencv2/core/core.hpp>
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
#include <opencv2/imgproc.hpp>
|
|
#include <spdlog/spdlog.h>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <tuple>
|
|
#include <vector>
|
|
|
|
class ImageManipulator {
|
|
public:
|
|
ImageManipulator() = delete;
|
|
ImageManipulator(const ImageManipulator& other) = delete;
|
|
ImageManipulator(ImageManipulator&& other) noexcept = delete;
|
|
ImageManipulator& operator=(const ImageManipulator& other) = delete;
|
|
ImageManipulator& operator=(ImageManipulator&& other) noexcept = delete;
|
|
|
|
// Load image from input, and prepare for output
|
|
ImageManipulator(std::filesystem::path const t_input_path,
|
|
std::filesystem::path const t_output_path,
|
|
int const iterations);
|
|
// ImageManipulator(cv::Mat const& t_origin_image,
|
|
// int const iterations,
|
|
// int const t_x,
|
|
// int const t_y,
|
|
// int const t_width,
|
|
// int const t_height);
|
|
|
|
void exec_method(int const t_nb_method, bool const t_controlled_size);
|
|
void write_file() const;
|
|
|
|
//! Destructor
|
|
virtual ~ImageManipulator() noexcept = default;
|
|
|
|
protected:
|
|
private:
|
|
[[nodiscard]] auto euclidian_distance(cv::Mat const& t_img) const noexcept
|
|
-> double;
|
|
[[nodiscard]] auto random_color() const noexcept;
|
|
[[nodiscard]] auto get_square_values() const noexcept;
|
|
[[nodiscard]] auto get_controlled_square_values() const noexcept;
|
|
[[nodiscard]] auto create_candidate(bool const t_controlled_size) const;
|
|
|
|
void get_color_set();
|
|
void threaded_get_color(int t_h);
|
|
void adjust_size(cv::Point& t_top_left, int const size) noexcept;
|
|
void draw_square(cv::Mat& t_img,
|
|
cv::Point const& t_top_left,
|
|
int const t_size,
|
|
cv::Scalar const& t_color) const;
|
|
void update_gen_image(cv::Mat const& t_img, double const t_diff);
|
|
void method1();
|
|
void method2();
|
|
void method3();
|
|
void method4(bool const t_controlled_size);
|
|
|
|
std::vector<std::array<uchar, 3>> colors_
|
|
= std::vector<std::array<uchar, 3>>{};
|
|
cv::Mat const reference_;
|
|
cv::Mat generated_image_;
|
|
std::mutex colors_mutex_ = std::mutex{};
|
|
std::string const output_path_;
|
|
double diff_ = 0.0;
|
|
int const total_iterations_ = 0;
|
|
int remaining_iter_ = 0;
|
|
int const width_;
|
|
int const height_;
|
|
};
|