36 lines
977 B
C++
36 lines
977 B
C++
#pragma once
|
|
#include <nlohmann/json.hpp>
|
|
#include <opencv2/core.hpp>
|
|
#include <filesystem>
|
|
#include <map>
|
|
#include <set>
|
|
using Json = nlohmann::ordered_json;
|
|
namespace cms {
|
|
struct DoorOptions {
|
|
std::filesystem::path constant, directory;
|
|
std::string format{"auto"};
|
|
std::set<std::string> 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<int, std::filesystem::path> paths_;
|
|
cv::Mat mask_, distance_;
|
|
bool cached_{};
|
|
};
|
|
double rounded(double value, int digits);
|
|
}
|