From d83ccff03d61fa212100c79551578b64d087db2d Mon Sep 17 00:00:00 2001 From: ackimixs Date: Wed, 24 Jan 2024 16:12:44 +0100 Subject: [PATCH] 4.6 --- aruco/ArucoDetector.cpp | 26 +++++++++++++++----------- aruco/ArucoDetector.h | 8 ++++---- arucoDetector.cpp | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/aruco/ArucoDetector.cpp b/aruco/ArucoDetector.cpp index f813dc8..f93c68f 100644 --- a/aruco/ArucoDetector.cpp +++ b/aruco/ArucoDetector.cpp @@ -3,12 +3,12 @@ ArucoDetector::ArucoDetector(const Type::RobotPose& pose, const std::string& calibrationPath, const Team team, const int cameraId, const bool headless) : robotPose(pose), headless(headless), team(team) { // opencv 4.8 - this->detector = cv::aruco::ArucoDetector(getPredefinedDictionary(cv::aruco::DICT_4X4_50), cv::aruco::DetectorParameters()); - this->dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); - this->parameters = cv::aruco::DetectorParameters(); + // this->detector = cv::aruco::ArucoDetector(getPredefinedDictionary(cv::aruco::DICT_4X4_50), cv::aruco::DetectorParameters()); + // this->dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); + // this->parameters = cv::aruco::DetectorParameters(); // 4.6 - // this->dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); + this->dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); this->transformationMatrix = (cv::Mat_(4, 4) << @@ -73,11 +73,6 @@ void ArucoDetector::addArucoTag(const ArucoTag& tag) std::pair>>> ArucoDetector::detectArucoTags(std::vector tags) { - if (tags.empty()) - { - tags = this->arucoTags; - } - if (!started) { std::pair>>> result; @@ -85,6 +80,11 @@ std::pair>>> Ar return result; } + if (tags.empty()) + { + tags = this->arucoTags; + } + cv::Mat frame; cap >> frame; // Capture frame from the camera @@ -102,10 +102,10 @@ std::pair>>> Ar std::vector> markerCorners; // 4.6 - // cv::aruco::detectMarkers(frame, this->dictionary, markerCorners, markerIds); + cv::aruco::detectMarkers(frame, this->dictionary, markerCorners, markerIds); // opencv 4.8 - detector.detectMarkers(frame, markerCorners, markerIds); + // detector.detectMarkers(frame, markerCorners, markerIds); if (!markerIds.empty()) { @@ -208,6 +208,10 @@ void ArucoDetector::solarPanelDetector(const ArucoTag& tag, cv::Mat translationM { std::cout << "Yellow side" << std::endl; } + else + { + std::cout << "Mid" << std::endl; + } // BLUE => 90, YELLOW => -90 } diff --git a/aruco/ArucoDetector.h b/aruco/ArucoDetector.h index 32aebc3..3f05eeb 100644 --- a/aruco/ArucoDetector.h +++ b/aruco/ArucoDetector.h @@ -14,12 +14,12 @@ class ArucoDetector { cv::VideoCapture cap; // 4.6 - // cv::Ptr dictionary; + cv::Ptr dictionary; // 4.8 - cv::aruco::Dictionary dictionary; - cv::aruco::DetectorParameters parameters; - cv::aruco::ArucoDetector detector; + // cv::aruco::Dictionary dictionary; + // cv::aruco::DetectorParameters parameters; + // cv::aruco::ArucoDetector detector; bool headless; diff --git a/arucoDetector.cpp b/arucoDetector.cpp index cbd0e9b..6bc298c 100644 --- a/arucoDetector.cpp +++ b/arucoDetector.cpp @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) auto solarPanel = ArucoTag(47, "Solar panel", 50, SOLAR_PANEL); while (true) { - const auto [code, res] = detector.detectArucoTags({solarPanel}); + const auto [code, res] = detector.detectArucoTags({whiteFlower, purpleFlower, solarPanel}); if (code == -2) {