2019-04-27 13:45:39 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
|
|
#include <opencv2/imgproc.hpp>
|
2019-04-27 16:04:32 +00:00
|
|
|
#include <spdlog/spdlog.h>
|
2019-04-27 13:45:39 +00:00
|
|
|
|
2019-04-27 14:27:22 +00:00
|
|
|
class Shape
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr int MAX_POINTS{4};
|
|
|
|
enum class ShapeType { Square, Triangle };
|
|
|
|
|
|
|
|
/// \brief Default constructor
|
|
|
|
Shape() = delete;
|
|
|
|
|
|
|
|
Shape(Shape::ShapeType const t_type);
|
|
|
|
|
|
|
|
/// \brief Copy constructor
|
|
|
|
Shape(const Shape &other) = default;
|
|
|
|
|
|
|
|
/// \brief Move constructor
|
|
|
|
Shape(Shape &&other) noexcept;
|
|
|
|
|
|
|
|
/// \brief Destructor
|
|
|
|
virtual ~Shape() noexcept = default;
|
|
|
|
|
|
|
|
/// \brief Copy assignment operator
|
|
|
|
Shape &operator=(const Shape &other) = delete;
|
|
|
|
|
|
|
|
/// \brief Move assignment operator
|
|
|
|
Shape &operator=(Shape &&other) noexcept = delete;
|
|
|
|
|
|
|
|
/// \brief Generates a shape's points
|
2019-04-27 16:04:32 +00:00
|
|
|
void update(cv::Point &&t_max_pos, int const t_max_size,
|
|
|
|
int const t_min_size = 0) noexcept;
|
2019-04-27 14:27:22 +00:00
|
|
|
|
|
|
|
[[nodiscard]] auto get_points() const noexcept
|
|
|
|
-> 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 &
|
|
|
|
{
|
|
|
|
return type_;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] auto get_nb_points() const noexcept
|
|
|
|
{
|
|
|
|
return nb_points_;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
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}};
|
|
|
|
int nb_points_{Shape::MAX_POINTS};
|
2019-04-27 13:45:39 +00:00
|
|
|
};
|