#pragma once #include #include #include #include #include using Json = nlohmann::ordered_json; namespace cms { struct DoorOptions { std::filesystem::path constant, directory; std::string format{"auto"}; std::set labels{"door", "车门"}; int offset{}; bool require{}; double warning{0.30}, release{0.45}; }; class DoorRisk { public: DoorRisk(DoorOptions options, cv::Size size); void initialize() { load(0); } Json evaluate(int frame, Json& record); cv::Mat const& mask() const { return mask_; } private: void load(int frame); cv::Mat rasterize(std::filesystem::path const& path) const; DoorOptions options_; cv::Size size_; std::string format_, status_; std::filesystem::path loadedPath_; std::map paths_; cv::Mat mask_, distance_; bool cached_{}; }; double rounded(double value, int digits); }