Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 1 | #ifndef FRC971_VISION_VISION_UTIL_LIB_H_ |
| 2 | #define FRC971_VISION_VISION_UTIL_LIB_H_ |
| 3 | #include <optional> |
| 4 | #include <string_view> |
| 5 | |
| 6 | #include "opencv2/imgproc.hpp" |
| 7 | |
| 8 | #include "frc971/vision/calibration_generated.h" |
| 9 | |
Jim Ostrowski | b974cca | 2024-01-28 15:07:50 -0800 | [diff] [blame] | 10 | // Extract the CameraExtrinsics from a CameraCalibration struct |
Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 11 | namespace frc971::vision { |
| 12 | std::optional<cv::Mat> CameraExtrinsics( |
| 13 | const frc971::vision::calibration::CameraCalibration *camera_calibration); |
| 14 | |
Jim Ostrowski | b974cca | 2024-01-28 15:07:50 -0800 | [diff] [blame] | 15 | // Extract the CameraIntrinsics from a CameraCalibration struct |
Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 16 | cv::Mat CameraIntrinsics( |
| 17 | const frc971::vision::calibration::CameraCalibration *camera_calibration); |
| 18 | |
Jim Ostrowski | b974cca | 2024-01-28 15:07:50 -0800 | [diff] [blame] | 19 | // Extract the CameraDistCoeffs from a CameraCalibration struct |
Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 20 | cv::Mat CameraDistCoeffs( |
| 21 | const frc971::vision::calibration::CameraCalibration *camera_calibration); |
| 22 | |
Jim Ostrowski | b974cca | 2024-01-28 15:07:50 -0800 | [diff] [blame] | 23 | // Get the camera number from a camera channel name, e.g., return 2 from |
| 24 | // "/camera2". Returns nullopt if string doesn't start with "/camera" or does |
| 25 | // not have a number |
| 26 | std::optional<uint16_t> CameraNumberFromChannel(std::string camera_channel); |
| 27 | |
Jim Ostrowski | 3320898 | 2024-03-02 15:01:45 -0800 | [diff] [blame] | 28 | // Return a calibration filename to save to based on the given data |
| 29 | std::string CalibrationFilename(std::string calibration_folder, |
| 30 | std::string node_name, int team_number, |
| 31 | int camera_number, std::string camera_id, |
| 32 | std::string timestamp); |
| 33 | |
Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 34 | } // namespace frc971::vision |
| 35 | |
| 36 | #endif // FRC971_VISION_VISION_UTIL_LIB_H_ |