#pragma once // Public downstream contract. Owns its data; no GPU, JSON or network handles. #include "image.hpp" #include "lazy_gate.hpp" #include #include #include #include #include #include namespace cms { struct DoorMaskResult { std::string status; int annotation_index{}; std::optional path; std::string format; int area_px{}; }; struct RegionRisk { std::string status; std::optional risk_score; std::string risk_level; std::string decision; std::string source; int track_id{}; std::string side; std::optional state; // Unavailable evidence has no geometric measurements, matching the reference. std::optional region_area_px, door_overlap_px; std::optional region_overlap_ratio, min_distance_px; std::optional region_scale_px, distance_relative; }; struct RiskResult { std::string status; std::optional risk_score; std::string risk_level; std::string decision; std::optional source; std::optional track_id; std::optional side; DoorMaskResult door_mask; double warning_distance_relative{}, release_distance_relative{}; std::vector regions; }; struct PosePoint { double x{},y{},score{}; }; struct HandState { std::string state, source; bool limb_consensus{}, distance_eligible{}, alarm_eligible{}; }; struct PersonResult { int track_id{}; double confidence{}; std::array box{}; std::array selected{}, smoothed{}, temporal{}; std::array hands; // left, right }; struct HandRegion { int person_id{},track_id{}; std::string side; std::array keypoints{}; }; struct StageTiming { double detector_ms{}, pose_ms{}, fusion_risk_ms{}, capture_to_result_ms{}; }; struct FrameResult { InferenceStatus inference; int frame_index{}; std::vector track_ids; std::vector> boxes; RiskResult risk; CaptureMetadata capture; StageTiming timing; std::vector persons; std::vector hand_regions; // Both images belong to this result. The constant mask is shared across frames. std::shared_ptr image; std::shared_ptr door_mask_pixels; bool door_mask_calibration_verified{}; }; using FrameResultPtr = std::shared_ptr; }