2019-03-19 14:26:03 +00:00
|
|
|
#include "drawing.hh"
|
2019-03-20 10:40:17 +00:00
|
|
|
#include <cstdlib>
|
2019-03-19 14:26:03 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <opencv2/imgproc.hpp>
|
2019-03-20 10:40:17 +00:00
|
|
|
#include <spdlog/spdlog.h>
|
2019-03-19 14:26:03 +00:00
|
|
|
|
2019-03-20 10:40:17 +00:00
|
|
|
void drawSquare(cv::Mat &t_img, cv::Point const &t_top_left, int const t_size,
|
2019-03-19 14:26:03 +00:00
|
|
|
cv::Scalar const &t_color) {
|
|
|
|
std::unique_ptr<cv::Point> points(new cv::Point[4]);
|
|
|
|
points.get()[0] = t_top_left;
|
2019-03-20 10:40:17 +00:00
|
|
|
points.get()[1] = cv::Point{t_top_left.x, t_top_left.y + t_size};
|
|
|
|
points.get()[2] = cv::Point{t_top_left.x + t_size, t_top_left.y + t_size};
|
|
|
|
points.get()[3] = cv::Point{t_top_left.x + t_size, t_top_left.y};
|
2019-03-19 14:26:03 +00:00
|
|
|
fillConvexPoly(t_img, points.get(), 4, t_color);
|
|
|
|
}
|
2019-03-20 10:40:17 +00:00
|
|
|
|
|
|
|
void draw_shape(cv::Mat &t_img, cv::Point const &t_top_left, int const t_size,
|
|
|
|
cv::Scalar const &t_color, Shapes const &t_shape) {
|
|
|
|
switch (t_shape) {
|
|
|
|
case Shapes::Square: {
|
|
|
|
drawSquare(t_img, t_top_left, t_size, t_color);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
spdlog::error("Shape does not exist. Aborting...");
|
|
|
|
std::exit(1);
|
|
|
|
}
|
|
|
|
}
|