12struct SensorCalibrationResult {
17SensorCalibrationResult calibrate_sensor(
const PlanarIntrinsicCalibrationFacade& facade,
18 const IntrinsicCalibrationConfig& cfg,
20 PipelineContext& context) {
21 SensorCalibrationResult result;
24 if (cam_cfg ==
nullptr) {
25 result.summary = nlohmann::json{
26 {
"sensor_id", sensor_id},
27 {
"status",
"missing_camera_config"},
33 auto run = facade.calibrate(cfg, *cam_cfg,
detections);
34 context.intrinsic_results[sensor_id] = run;
39 entry[
"sensor_id"] = sensor_id;
40 nlohmann::json tags = nlohmann::json::array();
42 entry[
"tags"] = std::move(tags);
44 result.success =
true;
45 result.summary = std::move(entry);
46 }
catch (
const std::exception& ex) {
47 result.summary = nlohmann::json{
48 {
"sensor_id", sensor_id}, {
"status",
"calibration_failed"}, {
"error", ex.what()}};
53void collect_gating_flags(
const std::vector<PlanarDetections>&
detections,
bool& has_synth,
58 if (det.tags.count(
"synthetic")) {
61 if (det.tags.count(
"recorded")) {
73 if (!context.has_intrinsics_config()) {
74 result.
summary[
"error"] =
"No intrinsics configuration supplied.";
78 if (context.dataset.planar_cameras.empty()) {
79 result.
summary[
"error"] =
"Dataset does not contain planar camera captures.";
84 const auto& cfg = context.intrinsics_config();
87 bool overall_success =
true;
88 nlohmann::json cameras = nlohmann::json::array();
89 for (
const auto&
detections : context.dataset.planar_cameras) {
90 auto sensor_result = calibrate_sensor(facade, cfg,
detections, context);
91 cameras.push_back(std::move(sensor_result.summary));
92 overall_success = overall_success && sensor_result.success;
95 bool has_synthetic =
false;
96 bool has_recorded =
false;
97 collect_gating_flags(context.dataset.planar_cameras, has_synthetic, has_recorded);
99 result.
summary[
"cameras"] = std::move(cameras);
100 result.
summary[
"gating"] = {{
"synthetic", has_synthetic}, {
"recorded", has_recorded}};
101 result.
success = overall_success && !context.intrinsic_results.empty();
auto run(PipelineContext &context) -> PipelineStageResult override
PlanarDetections detections
auto find_camera_config(const IntrinsicCalibrationConfig &cfg, const std::string &camera_id) -> const CameraConfig *
auto build_planar_intrinsics_report(const IntrinsicCalibrationConfig &cfg, const CameraConfig &cam_cfg, const PlanarDetections &detections, const IntrinsicCalibrationOutputs &outputs) -> CalibrationReport
void to_json(nlohmann::json &j, const T &value)
std::set< std::string > tags