clang format update

This commit is contained in:
Phuntsok Drak-pa 2019-04-27 16:27:22 +02:00
parent bc9dcf4142
commit b962d50996
7 changed files with 520 additions and 559 deletions

View File

@ -1,46 +1,39 @@
#pragma once
#include "shapes.hh"
#include <array>
#include <spdlog/spdlog.h>
#include <string>
#include <vector>
class ImageManipulator {
public:
class ImageManipulator
{
public:
ImageManipulator() = delete;
/// \brief Copy contructor
ImageManipulator(const ImageManipulator& other);
ImageManipulator(const ImageManipulator &other);
/// \brief Move constructor
ImageManipulator(ImageManipulator&& other) noexcept;
ImageManipulator(ImageManipulator &&other) noexcept;
/// \brief Load image from input, and prepare for output
ImageManipulator(std::string const t_input_path,
std::string const t_output_path,
int const iterations,
std::string const t_output_path, int const iterations,
Shape::ShapeType const t_shape);
/// \brief Basically makes views from image
ImageManipulator(cv::Mat const& t_origin_image,
int const t_iterations,
Shape::ShapeType const t_shape,
int const t_x,
int const t_y,
int const t_width,
int const t_height);
ImageManipulator(cv::Mat const &t_origin_image, int const t_iterations,
Shape::ShapeType const t_shape, int const t_x, int const t_y,
int const t_width, int const t_height);
[[nodiscard]] auto operator=(ImageManipulator& other) = delete;
[[nodiscard]] auto operator=(ImageManipulator &other) = delete;
[[nodiscard]] auto operator=(ImageManipulator&& other) noexcept = delete;
[[nodiscard]] auto operator=(ImageManipulator &&other) noexcept = delete;
/// \brief Execute the nth method on the current object
void exec_method(int const t_nb_method,
bool const t_controlled_size,
int const t_cols,
int const t_rows,
int const t_submethod);
void exec_method(int const t_nb_method, bool const t_controlled_size,
int const t_cols, int const t_rows, int const t_submethod);
/**
* \brief Write the generated image to the output path
@ -54,7 +47,7 @@ class ImageManipulator {
}
/// \brief Returns a reference to the generated image
[[nodiscard]] inline auto const& get_generated_image() const noexcept
[[nodiscard]] inline auto const &get_generated_image() const noexcept
{
return generated_image_;
}
@ -62,12 +55,12 @@ class ImageManipulator {
/// \brief Destructor
virtual ~ImageManipulator() noexcept = default;
protected:
private:
protected:
private:
// methods //////////////////////////////////////////////////////////////////
/// \brief Calculates the euclidian distance between two images
[[nodiscard]] auto euclidian_distance(cv::Mat const& t_img) const noexcept
[[nodiscard]] auto euclidian_distance(cv::Mat const &t_img) const noexcept
-> double;
/// \brief Creates and returns a random color
@ -93,18 +86,19 @@ class ImageManipulator {
void threaded_get_color(int const t_h);
/// \brief Draw a square on an image
[[deprecated]] void draw_square(cv::Mat& t_img,
cv::Point const& t_top_left,
[[deprecated]] void draw_square(cv::Mat &t_img, cv::Point const &t_top_left,
int const t_size,
cv::Scalar const& t_color) const;
cv::Scalar const &t_color) const;
void draw_shape(cv::Mat& t_img, cv::Scalar&& t_color);
void draw_shape(cv::Mat &t_img, cv::Scalar &&t_color);
void create_shape() noexcept;
void create_controlled_shape() noexcept;
/// \brief Update this objects generated image
void update_gen_image(cv::Mat const& t_img, double const t_diff);
void update_gen_image(cv::Mat const &t_img, double const t_diff);
/// \brief Merges tiles generated by method5
void merge_tiles(std::vector<std::vector<ImageManipulator>> const& t_tiles);
void merge_tiles(std::vector<std::vector<ImageManipulator>> const &t_tiles);
/// \brief First method as described in the
/// [report](https://labs.phundrak.fr/phundrak/genetic-images/blob/master/report/report.pdf)
@ -124,9 +118,7 @@ class ImageManipulator {
/// \brief Fifth method as described in the
/// [report](https://labs.phundrak.fr/phundrak/genetic-images/blob/master/report/report.pdf)
void method5(bool const t_controlled_size,
int const cols,
int const rows,
void method5(bool const t_controlled_size, int const cols, int const rows,
int const submethod);
// members //////////////////////////////////////////////////////////////////

View File

@ -1,8 +1,9 @@
#pragma once
#include <filesystem>
#include "shapes.hh"
#include <filesystem>
struct ParsedArgs {
std::filesystem::path input_path;
std::filesystem::path output_path;
@ -17,4 +18,4 @@ struct ParsedArgs {
};
/// \brief Parses the arguments passed to the program
[[nodiscard]] auto parse_args(int, char**) -> ParsedArgs;
[[nodiscard]] auto parse_args(int, char **) -> ParsedArgs;

View File

@ -4,8 +4,9 @@
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
class Shape {
public:
class Shape
{
public:
static constexpr int MAX_POINTS{4};
enum class ShapeType { Square, Triangle };
@ -15,47 +16,48 @@ class Shape {
Shape(Shape::ShapeType const t_type);
/// \brief Copy constructor
Shape(const Shape& other) = default;
Shape(const Shape &other) = default;
/// \brief Move constructor
Shape(Shape&& other) noexcept;
Shape(Shape &&other) noexcept;
/// \brief Destructor
virtual ~Shape() noexcept = default;
/// \brief Copy assignment operator
Shape& operator=(const Shape& other) = delete;
Shape &operator=(const Shape &other) = delete;
/// \brief Move assignment operator
Shape& operator=(Shape&& other) noexcept = delete;
Shape &operator=(Shape &&other) noexcept = delete;
/// \brief Generates a shape's points
void operator()(cv::Point&& t_max_pos,
int const t_max_size,
void operator()(cv::Point &&t_max_pos, int const t_max_size,
int const t_min_size = 0) noexcept;
[[nodiscard]] auto get_points() const noexcept
-> std::array<cv::Point, Shape::MAX_POINTS> const&
-> std::array<cv::Point, Shape::MAX_POINTS> const &
{
return points_;
}
/// \brief Returns the type of shape described by the object
[[nodiscard]] auto get_type() const noexcept -> ShapeType const&
[[nodiscard]] auto get_type() const noexcept -> ShapeType const &
{
return type_;
}
[[nodiscard]] auto get_nb_points() const noexcept { return nb_points_; }
[[nodiscard]] auto get_nb_points() const noexcept
{
return nb_points_;
}
protected:
private:
void create_square_points(cv::Point const& t_top_left,
protected:
private:
void create_square_points(cv::Point const &t_top_left,
int const t_size) noexcept;
void create_triangle_points(cv::Point const& t_top_left,
void create_triangle_points(cv::Point const &t_top_left,
int const t_size) noexcept;
ShapeType const type_{ShapeType::Square};
std::array<cv::Point, Shape::MAX_POINTS> points_{
cv::Point{0, 0}, cv::Point{0, 0}, cv::Point{0, 0}, cv::Point{0, 0}};

View File

@ -1,10 +1,11 @@
#include "methods.hh"
#include "parseargs.hh"
#include <cstdlib>
#include <ctime>
#include <iostream>
int main(int ac, char** av)
int main(int ac, char **av)
{
std::srand(std::time(nullptr));
auto const arguments = parse_args(ac, av);

View File

@ -1,4 +1,5 @@
#include "methods.hh"
#include <algorithm>
#include <future>
#include <optional>
@ -17,16 +18,12 @@ static auto const thread_nbr = std::thread::hardware_concurrency();
*
* \param[in] other Element to copy
*/
ImageManipulator::ImageManipulator(const ImageManipulator& other)
: colors_{other.colors_},
reference_{other.reference_},
generated_image_{other.generated_image_},
shape_{other.shape_},
output_path_{other.output_path_},
diff_{other.diff_},
ImageManipulator::ImageManipulator(const ImageManipulator &other)
: colors_{other.colors_}, reference_{other.reference_},
generated_image_{other.generated_image_}, shape_{other.shape_},
output_path_{other.output_path_}, diff_{other.diff_},
total_iterations_{other.total_iterations_},
remaining_iter_{other.remaining_iter_},
width_{other.width_},
remaining_iter_{other.remaining_iter_}, width_{other.width_},
height_{other.height_}
{
}
@ -37,16 +34,14 @@ ImageManipulator::ImageManipulator(const ImageManipulator& other)
*
* \param[in] other Element to move
*/
ImageManipulator::ImageManipulator(ImageManipulator&& other) noexcept
: colors_{std::move(other.colors_)},
reference_{std::move(other.reference_)},
generated_image_{std::move(other.generated_image_)},
shape_{std::move(other.shape_)},
ImageManipulator::ImageManipulator(ImageManipulator &&other) noexcept
: colors_{std::move(other.colors_)}, reference_{std::move(
other.reference_)},
generated_image_{std::move(other.generated_image_)}, shape_{std::move(
other.shape_)},
output_path_{std::move(other.output_path_)},
diff_{std::move(other.diff_)},
total_iterations_{other.total_iterations_},
remaining_iter_{other.remaining_iter_},
width_{other.width_},
diff_{std::move(other.diff_)}, total_iterations_{other.total_iterations_},
remaining_iter_{other.remaining_iter_}, width_{other.width_},
height_{other.height_}
{
}
@ -63,10 +58,9 @@ ImageManipulator::ImageManipulator(std::string const t_input_path,
std::string const t_output_path,
int const t_iterations,
Shape::ShapeType const t_shape)
: reference_{cv::imread(t_input_path, cv::IMREAD_COLOR)},
shape_{Shape{t_shape}},
output_path_{t_output_path},
total_iterations_{t_iterations}
: reference_{cv::imread(t_input_path, cv::IMREAD_COLOR)}, shape_{Shape{
t_shape}},
output_path_{t_output_path}, total_iterations_{t_iterations}
{
if (!reference_.data) {
spdlog::critical("Could not open or find image!\n");
@ -85,18 +79,15 @@ ImageManipulator::ImageManipulator(std::string const t_input_path,
* \param[in] t_width Width of the view from its origin
* \param[in] t_height Height of the view from its origin
*/
ImageManipulator::ImageManipulator(cv::Mat const& t_origin_image,
ImageManipulator::ImageManipulator(cv::Mat const &t_origin_image,
int const t_iterations,
Shape::ShapeType const t_shape,
int const t_x,
int const t_y,
int const t_width,
int const t_height)
int const t_x, int const t_y,
int const t_width, int const t_height)
: reference_{t_origin_image(
cv::Range{t_y, std::min(t_y + t_height, t_origin_image.rows)},
cv::Range{t_x, std::min(t_x + t_width, t_origin_image.cols)})},
shape_{Shape{t_shape}},
total_iterations_{t_iterations}
shape_{Shape{t_shape}}, total_iterations_{t_iterations}
{
if (!reference_.data) {
spdlog::critical("Could not open or find image!\n");
@ -121,31 +112,15 @@ ImageManipulator::ImageManipulator(cv::Mat const& t_origin_image,
*/
void ImageManipulator::exec_method(int const t_nb_method,
bool const t_controlled_size = false,
int const t_cols = 1,
int const t_rows = 0,
int const t_cols = 1, int const t_rows = 0,
int const t_submethod = 1)
{
switch (t_nb_method) {
case 1: {
method1();
break;
}
case 2: {
method2();
break;
}
case 3: {
method3();
break;
}
case 4: {
method4(t_controlled_size);
break;
}
case 5: {
method5(t_controlled_size, t_cols, t_rows, t_submethod);
break;
}
case 1: method1(); break;
case 2: method2(); break;
case 3: method3(); break;
case 4: method4(t_controlled_size); break;
case 5: method5(t_controlled_size, t_cols, t_rows, t_submethod); break;
default:
spdlog::error("Requested method {} is not implemented.", t_nb_method);
std::exit(-1);
@ -165,8 +140,9 @@ void ImageManipulator::exec_method(int const t_nb_method,
* \param t_img Image with which the distance is computed
* \return double
*/
[[nodiscard]] auto ImageManipulator::euclidian_distance(
cv::Mat const& t_img) const noexcept -> double
[[nodiscard]] auto
ImageManipulator::euclidian_distance(cv::Mat const &t_img) const noexcept
-> double
{
double euclidian = 0.0;
for (auto itr1 = reference_.begin<uchar>(), itr2 = t_img.begin<uchar>();
@ -224,6 +200,26 @@ void ImageManipulator::exec_method(int const t_nb_method,
return std::tuple<int, int, int>(rand_x, rand_y, size);
}
void ImageManipulator::create_shape() noexcept
{
shape_(cv::Point{reference_.size().width, reference_.size().height},
std::min(reference_.size().width, reference_.size().height));
}
void ImageManipulator::create_controlled_shape() noexcept
{
float const coef = static_cast<float>(remaining_iter_)
/ static_cast<float>(total_iterations_);
int const min_size
= static_cast<int>((static_cast<float>(std::min(reference_.size().width,
reference_.size().height))
/ 2.0f)
* coef);
int const max_size = min_size * 2 + 1;
shape_(cv::Point{reference_.size().width, reference_.size().height}, max_size,
min_size);
}
/**
* Creates a temporary image on which a random square is drawn. If its
* euclidian distance with the reference image proves to be an improvement from
@ -233,31 +229,14 @@ void ImageManipulator::exec_method(int const t_nb_method,
* \param[in] t_controlled_size Enables controlled square size
* \return Optional pair of cv::Mat and double
*/
[[nodiscard]] auto ImageManipulator::create_candidate(
bool const t_controlled_size = false)
[[nodiscard]] auto
ImageManipulator::create_candidate(bool const t_controlled_size = false)
{
auto temp_img = generated_image_.clone();
auto create_shape = [&]() {
return shape_(cv::Point{reference_.size().width, reference_.size().height},
std::min(reference_.size().width, reference_.size().height));
};
auto create_controlled_shape = [&]() {
float const coef = static_cast<float>(remaining_iter_)
/ static_cast<float>(total_iterations_);
int const min_size = static_cast<int>(
(static_cast<float>(
std::min(reference_.size().width, reference_.size().height))
/ 2.0f)
* coef);
int const max_size = min_size * 2 + 1;
return shape_(cv::Point{reference_.size().width, reference_.size().height},
max_size, min_size);
};
auto const& color = colors_[rand() % colors_.size()];
auto const &color = colors_[rand() % colors_.size()];
if (t_controlled_size) {
create_shape();
}
else {
} else {
create_controlled_shape();
}
draw_shape(temp_img, cv::Scalar{static_cast<double>(color[0]),
@ -315,7 +294,7 @@ void ImageManipulator::get_color_set()
std::thread(&ImageManipulator::threaded_get_color, this, h + i));
}
std::for_each(thread_list.begin(), thread_list.end(),
[](auto& th) { th.join(); });
[](auto &th) { th.join(); });
}
colors_.shrink_to_fit();
}
@ -353,10 +332,9 @@ void ImageManipulator::threaded_get_color(int const t_h)
* \param[in] t_size Size of the square
* \param[in] t_color Color of the square
*/
void ImageManipulator::draw_square(cv::Mat& t_img,
cv::Point const& t_top_left,
void ImageManipulator::draw_square(cv::Mat &t_img, cv::Point const &t_top_left,
int const t_size,
cv::Scalar const& t_color) const
cv::Scalar const &t_color) const
{
std::array<cv::Point, 4> points
= {t_top_left, cv::Point{t_top_left.x, t_top_left.y + t_size},
@ -365,7 +343,7 @@ void ImageManipulator::draw_square(cv::Mat& t_img,
fillConvexPoly(t_img, points.data(), 4, t_color);
}
void ImageManipulator::draw_shape(cv::Mat& t_img, cv::Scalar&& t_color)
void ImageManipulator::draw_shape(cv::Mat &t_img, cv::Scalar &&t_color)
{
fillConvexPoly(t_img, shape_.get_points().data(), shape_.get_nb_points(),
t_color);
@ -381,7 +359,7 @@ void ImageManipulator::draw_shape(cv::Mat& t_img, cv::Scalar&& t_color)
* \param[in] t_img Image to replace \ref generated_image_
* \param[in] t_diff New euclidian distance
*/
void ImageManipulator::update_gen_image(cv::Mat const& t_img,
void ImageManipulator::update_gen_image(cv::Mat const &t_img,
double const t_diff)
{
diff_ = t_diff;
@ -398,13 +376,13 @@ void ImageManipulator::update_gen_image(cv::Mat const& t_img,
* \param t_tiles Collection of tiles to be merged together
*/
void ImageManipulator::merge_tiles(
std::vector<std::vector<ImageManipulator>> const& t_tiles)
std::vector<std::vector<ImageManipulator>> const &t_tiles)
{
std::vector<cv::Mat> columns{};
std::for_each(t_tiles.begin(), t_tiles.end(), [&columns](auto const& col) {
std::for_each(t_tiles.begin(), t_tiles.end(), [&columns](auto const &col) {
std::vector<cv::Mat> column_arr{};
cv::Mat column_img{};
std::for_each(col.begin(), col.end(), [&column_arr](auto const& tile) {
std::for_each(col.begin(), col.end(), [&column_arr](auto const &tile) {
column_arr.push_back(tile.get_generated_image());
});
vconcat(column_arr, column_img);
@ -418,8 +396,8 @@ void ImageManipulator::method1()
spdlog::debug("Beginning method1, initial difference: {}", diff_);
while (remaining_iter_ > 0 && diff_ > 0.0) {
auto temp_image = generated_image_.clone();
auto const [rand_x, rand_y, size] = get_square_values();
draw_square(temp_image, cv::Point{rand_x, rand_y}, size, random_color());
create_shape();
draw_shape(temp_image, random_color());
if (auto const new_diff = euclidian_distance(temp_image);
new_diff < diff_) {
update_gen_image(temp_image, new_diff);
@ -474,7 +452,7 @@ void ImageManipulator::method4(bool const t_controlled_size)
t_controlled_size));
}
// if candidate is a success, store it
std::for_each(results.begin(), results.end(), [&values, this](auto& elem) {
std::for_each(results.begin(), results.end(), [&values, this](auto &elem) {
if (auto res = elem.get(); res.has_value() && res->second < this->diff_) {
values.push_back(*res);
}
@ -483,7 +461,7 @@ void ImageManipulator::method4(bool const t_controlled_size)
if (values.size() > 0) {
auto const pos
= std::min_element(std::begin(values), std::end(values),
[](const auto& elem1, const auto& elem2) {
[](const auto &elem1, const auto &elem2) {
return elem1.second < elem2.second;
});
update_gen_image(pos->first, pos->second);
@ -497,10 +475,8 @@ void ImageManipulator::method4(bool const t_controlled_size)
* \param[in] t_rows Number of rows the reference should be divided into
* \param[in] t_submethod Method to be used on each tile
*/
void ImageManipulator::method5(bool const t_controlled_size,
int const t_cols,
int const t_rows,
int const t_submethod)
void ImageManipulator::method5(bool const t_controlled_size, int const t_cols,
int const t_rows, int const t_submethod)
{
spdlog::debug("Beginning method5, initial difference: {}", diff_);
spdlog::debug("Running on {} threads", thread_nbr);
@ -509,13 +485,13 @@ void ImageManipulator::method5(bool const t_controlled_size,
spdlog::debug("{} tiles", tiles.size());
std::vector<std::thread> thread_list{};
std::for_each(tiles.begin(), tiles.end(), [&](auto& row) {
std::for_each(row.begin(), row.end(), [&](auto& tile) {
std::for_each(tiles.begin(), tiles.end(), [&](auto &row) {
std::for_each(row.begin(), row.end(), [&](auto &tile) {
thread_list.emplace_back(
[&]() { tile.exec_method(t_submethod, t_controlled_size); });
});
});
std::for_each(thread_list.begin(), thread_list.end(),
[](auto& th) { th.join(); });
[](auto &th) { th.join(); });
merge_tiles(tiles);
}

View File

@ -1,4 +1,5 @@
#include "parseargs.hh"
#include <boost/program_options.hpp>
#include <iostream>
@ -19,15 +20,13 @@ namespace po = boost::program_options;
* \param[out] t_input Input path
* \param[out] t_output Output path
*/
void processFilenames(po::variables_map const& t_vm,
path const& t_input,
path& t_output)
void processFilenames(po::variables_map const &t_vm, path const &t_input,
path &t_output)
{
if (!t_vm.count("output")) {
t_output.replace_filename("output_"
+ std::string{t_input.filename().string()});
}
else if (!t_output.has_extension()) {
} else if (!t_output.has_extension()) {
t_output.replace_extension(".png");
}
}
@ -42,29 +41,30 @@ void processFilenames(po::variables_map const& t_vm,
* \param[in] t_av Arguments passed to the program
* \return Tuple of path, path, int, int, int, int, int, bool and bool
*/
[[nodiscard]] auto parse_args(int t_ac, char** t_av) -> ParsedArgs
[[nodiscard]] auto parse_args(int t_ac, char **t_av) -> ParsedArgs
{
ParsedArgs ret{};
po::options_description desc("Allowed options");
desc.add_options()("help,h", "Display this help message")(
"input,i", po::value<path>(), "Input image")(
"output,o", po::value<path>(),
"Image output path (default: \"output_\" + input path)")(
"iterations,n", po::value<int>(), "Number of iterations (default: 2000)")(
"method,m", po::value<int>(), "Method number to be used (default: 1)")(
"form,f", po::value<int>(), "Select shape (1:square, 2:triangle)")(
"cols,c", po::value<int>(),
desc.add_options()
("help,h", "Display this help message")
("input,i", po::value<path>(), "Input image")
("output,o", po::value<path>(),
"Image output path (default: \"output_\" + input path)")
("iterations,n", po::value<int>(), "Number of iterations (default: 2000)")
("method,m", po::value<int>(), "Method number to be used (default: 1)")
("form,f", po::value<int>(), "Select shape (1:square, 2:triangle)")
("cols,c", po::value<int>(),
"For method 5 only, number of columns the reference image should be "
"divided into. If the value is equal to 0, then it will be assumed "
"there will be as many rows as there are collumns. (default: 0)")(
"rows,r", po::value<int>(),
"there will be as many rows as there are collumns. (default: 0)")
("rows,r", po::value<int>(),
"For method 5 only, number of rows the reference image should be "
"divided into. (default: 1)")(
"submethod,S", po::value<int>(),
"divided into. (default: 1)")
("submethod,S", po::value<int>(),
"Sub-method that will be used to generate the individual tiles from "
"method 5. (default: 1)")("size,s",
"Enables controlled size of the random shapes")(
"verbose,v", "Enables verbosity");
"method 5. (default: 1)")
("size,s", "Enables controlled size of the random shapes")
("verbose,v", "Enables verbosity");
po::variables_map vm;
po::store(po::parse_command_line(t_ac, t_av, desc), vm);
po::notify(vm);
@ -84,14 +84,9 @@ void processFilenames(po::variables_map const& t_vm,
: DEFAULT_ITERATIONS;
ret.method = vm.count("method") ? vm["method"].as<int>() : 1;
switch (vm.count("form") ? vm["form"].as<int>() : 1) {
case 2:
ret.shape= Shape::ShapeType::Triangle;
break;
case 1:
[[fallthrough]];
default:
ret.shape = Shape::ShapeType::Square;
break;
case 2: ret.shape = Shape::ShapeType::Triangle; break;
case 1: [[fallthrough]];
default: ret.shape = Shape::ShapeType::Square; break;
}
ret.cols = vm.count("cols") ? vm["cols"].as<int>() : 0;

View File

@ -1,4 +1,5 @@
#include "shapes.hh"
#include <cmath>
#include <utility>
@ -11,17 +12,13 @@ Shape::Shape(Shape::ShapeType const t_type) : type_{t_type}
nb_points_ = 3;
break;
}
case ShapeType::Square:
[[fallthrough]];
default:
nb_points_ = 4;
break;
case ShapeType::Square: [[fallthrough]];
default: nb_points_ = 4; break;
}
}
Shape::Shape(Shape&& other) noexcept
: type_{std::move(other.type_)},
points_{std::move(other.points_)},
Shape::Shape(Shape &&other) noexcept
: type_{std::move(other.type_)}, points_{std::move(other.points_)},
nb_points_{std::move(other.nb_points_)}
{
}
@ -34,8 +31,7 @@ Shape::Shape(Shape&& other) noexcept
* for
* \return Array of points describing the shape
*/
void Shape::operator()(cv::Point&& t_max_pos,
int const t_max_size,
void Shape::operator()(cv::Point &&t_max_pos, int const t_max_size,
int const t_min_size) noexcept
{
int const size = (rand() % (t_max_size - t_min_size)) + t_min_size;
@ -43,14 +39,12 @@ void Shape::operator()(cv::Point&& t_max_pos,
= {rand() % (t_max_pos.x - size), rand() % (t_max_pos.y - size)};
if (type_ == ShapeType::Triangle) {
create_triangle_points(top_left, size);
}
else { // ShapeType::Square
} else { // ShapeType::Square
create_square_points(top_left, size);
}
}
void Shape::create_triangle_points(cv::Point const& t_top_left,
void Shape::create_triangle_points(cv::Point const &t_top_left,
int const t_size) noexcept
{
bool top_left = rand() % 1 == 0;
@ -62,7 +56,7 @@ void Shape::create_triangle_points(cv::Point const& t_top_left,
cv::Point{0, 0}};
}
void Shape::create_square_points(cv::Point const& t_top_left,
void Shape::create_square_points(cv::Point const &t_top_left,
int const t_size) noexcept
{
points_ = {cv::Point{t_top_left.x, t_top_left.y},