James (Peilun) Li | a70e575 | 2024-09-18 20:43:00 -0700 | [diff] [blame] | 1 | #ifndef Y2024_BOT3_VISION_VISION_UTIL_H_ |
| 2 | #define Y2024_BOT3_VISION_VISION_UTIL_H_ |
| 3 | #include <map> |
| 4 | #include <string_view> |
| 5 | |
| 6 | #include "opencv2/imgproc.hpp" |
| 7 | |
| 8 | #include "y2024_bot3/constants/constants_generated.h" |
| 9 | |
| 10 | namespace y2024_bot3::vision { |
| 11 | |
| 12 | // Generate unique colors for each camera |
| 13 | const auto kOrinColors = std::map<std::string, cv::Scalar>{ |
| 14 | {"/orin1/camera0", cv::Scalar(255, 0, 255)}, |
| 15 | {"/orin1/camera1", cv::Scalar(255, 255, 0)}, |
| 16 | {"/imu/camera0", cv::Scalar(0, 255, 255)}, |
| 17 | {"/imu/camera1", cv::Scalar(255, 165, 0)}, |
| 18 | }; |
| 19 | |
| 20 | // Structure to store node name (e.g., orin1, imu), number, and a usable string |
| 21 | struct CameraNode { |
| 22 | std::string node_name; |
| 23 | int camera_number; |
| 24 | |
| 25 | inline const std::string camera_name() const { |
| 26 | return "/" + node_name + "/camera" + std::to_string(camera_number); |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | std::vector<CameraNode> CreateNodeList(); |
| 31 | |
| 32 | std::map<std::string, int> CreateOrderingMap( |
| 33 | std::vector<CameraNode> &node_list); |
| 34 | |
| 35 | const frc971::vision::calibration::CameraCalibration *FindCameraCalibration( |
| 36 | const y2024_bot3::Constants &calibration_data, std::string_view node_name, |
| 37 | int camera_number); |
| 38 | |
| 39 | } // namespace y2024_bot3::vision |
| 40 | |
| 41 | #endif // Y2024_BOT3_VISION_VISION_UTIL_H_ |