From 8ceec47f7748daf0f5d16434911dfe2d8ab43d36 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Wed, 17 Jan 2024 22:44:20 +0100 Subject: [PATCH] arucoTag class --- utils/ArucoTag.cpp | 1 + utils/ArucoTag.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 utils/ArucoTag.cpp create mode 100644 utils/ArucoTag.h diff --git a/utils/ArucoTag.cpp b/utils/ArucoTag.cpp new file mode 100644 index 0000000..42ec1bb --- /dev/null +++ b/utils/ArucoTag.cpp @@ -0,0 +1 @@ +#include "ArucoTag.h" diff --git a/utils/ArucoTag.h b/utils/ArucoTag.h new file mode 100644 index 0000000..0bff2af --- /dev/null +++ b/utils/ArucoTag.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include + +enum ArucoTagType +{ + FLOWER, + SOLAR_PANEL +}; + +class ArucoTag { +public: + int id; + std::string name; + float length; + cv::Mat objectRepresenation; + ArucoTagType type; + + ArucoTag(const int id, std::string name, const float length, const ArucoTagType type) : id(id), name(std::move(name)), length(length), type(type) + { + this->objectRepresenation = cv::Mat(4, 1, CV_32FC3); + this->objectRepresenation.ptr(0)[0] = cv::Vec3f(-length/2.f, length/2.f, 0); + this->objectRepresenation.ptr(0)[1] = cv::Vec3f(length/2.f, length/2.f, 0); + this->objectRepresenation.ptr(0)[2] = cv::Vec3f(length/2.f, -length/2.f, 0); + this->objectRepresenation.ptr(0)[3] = cv::Vec3f(-length/2.f, -length/2.f, 0); + } + + void setFlowerObjectRepresentation() + { + this->objectRepresenation.ptr(0)[0] = cv::Vec3f(-length/2.f, length/2.f, 0); + this->objectRepresenation.ptr(0)[1] = cv::Vec3f(length/2.f, length/2.f, 0); + this->objectRepresenation.ptr(0)[2] = cv::Vec3f(length/2.f, -length/2.f, 0); + this->objectRepresenation.ptr(0)[3] = cv::Vec3f(-length/2.f, -length/2.f, 0); + } +};