// Copyright 2022 Chen Jun // Licensed under the MIT License. #ifndef PNP_SOLVER_HPP_ #define PNP_SOLVER_HPP_ //#include #include // STD #include #include #include "Blade.h" namespace rm_power_rune { class PnPSolver { public: PnPSolver( const std::array & camera_matrix, const std::vector & distortion_coefficients); // Get 3d position bool solvePnP(const Blade & blade, cv::Mat & rvec, cv::Mat & tvec); // Calculate the distance between armor center and image center float calculateDistanceToCenter(const cv::Point2f & image_point); private: cv::Mat camera_matrix_; cv::Mat dist_coeffs_; // Unit: mm static constexpr float SMALL_ARMOR_WIDTH = 135; static constexpr float SMALL_ARMOR_HEIGHT = 55; static constexpr float LARGE_ARMOR_WIDTH = 225; static constexpr float LARGE_ARMOR_HEIGHT = 55; // Four vertices of armor in 3d std::vector armor_points_; }; } // namespace rm_power_rune #endif // PNP_SOLVER_HPP_