diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fc1746..38ff5ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ include_directories( ${OpenCV_INCLUDE_DIRS} ) set(COMMON_SOURCES + utils/utils.h ) set(calibrationSources diff --git a/utils/utils.h b/utils/utils.h new file mode 100644 index 0000000..716e74b --- /dev/null +++ b/utils/utils.h @@ -0,0 +1,63 @@ +#pragma once + +#include +#include +#include +#include + +namespace utils { + void waitForUserInput() + { + std::cout << "Press Enter to continue..."; + std::cin.ignore(std::numeric_limits::max(), '\n'); + + } +} + + +namespace Type +{ + struct Angle + { + float roll; + float pitch; + float yaw; + }; + + struct RobotPose + { + cv::Point3f position; + Angle angle; + }; + + struct ArucoTag + { + int id; + std::string name; + float length; + }; +} + +namespace ArucoTagData +{ + inline Type::ArucoTag whiteFlower = { 36, "whiteFlower", 0.02f }; + inline Type::ArucoTag purpleFlower = { 13, "purpleFlower", 0.02f }; + inline Type::ArucoTag solarPanel = { 47, "solarPanel", 0.1f }; +} + +namespace draw +{ + // Function to draw a line from the center of an ArUco marker to a point with depth + void drawCenterPoints(cv::Mat& frame, const std::vector>& markerCorners, double depth) { + for (const auto& corners : markerCorners) { + cv::Point2f center(0, 0); + for (const auto& corner : corners) { + center += corner; + } + center *= (1.0 / corners.size()); // Average to find the center + + // Draw a line from the center of the marker to the point with depth + cv::line(frame, center, cv::Point(center.x, center.y + depth), cv::Scalar(0, 255, 0), 2); // Draw a green line + } + } +} \ No newline at end of file