Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 1 | #include "y2024/vision/vision_util.h" |
| 2 | |
| 3 | #include "glog/logging.h" |
| 4 | |
| 5 | namespace y2024::vision { |
| 6 | |
| 7 | const frc971::vision::calibration::CameraCalibration *FindCameraCalibration( |
Jim Ostrowski | ddebdcb | 2024-02-29 22:25:36 -0800 | [diff] [blame] | 8 | const y2024::Constants &calibration_data, std::string_view node_name, |
| 9 | int camera_number) { |
Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 10 | CHECK(calibration_data.has_cameras()); |
| 11 | for (const y2024::CameraConfiguration *candidate : |
| 12 | *calibration_data.cameras()) { |
| 13 | CHECK(candidate->has_calibration()); |
Jim Ostrowski | ddebdcb | 2024-02-29 22:25:36 -0800 | [diff] [blame] | 14 | if (candidate->calibration()->node_name()->string_view() != node_name || |
| 15 | candidate->calibration()->camera_number() != camera_number) { |
Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 16 | continue; |
| 17 | } |
| 18 | return candidate->calibration(); |
| 19 | } |
Jim Ostrowski | ddebdcb | 2024-02-29 22:25:36 -0800 | [diff] [blame] | 20 | LOG(FATAL) << ": Failed to find camera calibration for " << node_name |
| 21 | << " and camera number " << camera_number; |
Jim Ostrowski | cb8b408 | 2024-01-21 02:23:46 -0800 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | } // namespace y2024::vision |