64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
#include <opencv2/imgproc.hpp>
|
|
|
|
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
|
|
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&
|
|
{
|
|
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};
|
|
};
|