34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <opencv2/core.hpp>
|
|
#include <string>
|
|
|
|
namespace cms {
|
|
struct BrightnessGateConfig {
|
|
bool enabled{true};
|
|
double roi_x1{0.02}, roi_y1{0.05}, roi_x2{0.88}, roi_y2{0.98};
|
|
double dark_pixel_luma{40.0};
|
|
double enter_median_luma{18.0}, enter_dark_ratio{0.85}, enter_dark_tile_ratio{0.75};
|
|
double exit_median_luma{24.0}, exit_dark_ratio{0.80}, exit_dark_tile_ratio{0.70};
|
|
int startup_frames{5}, enter_frames{15}, exit_frames{15};
|
|
};
|
|
|
|
struct BrightnessDecision {
|
|
std::string state{"INITIALIZING"}, reason{"initializing"}, transition;
|
|
bool allow_downstream{};
|
|
double median_luma{}, p75_luma{}, mean_luma{}, dark_pixel_luma{40.0}, dark_ratio{}, dark_tile_ratio{};
|
|
int dark_streak{}, bright_streak{};
|
|
int enter_frames{}, exit_frames{};
|
|
};
|
|
|
|
class BrightnessGate {
|
|
public:
|
|
explicit BrightnessGate(BrightnessGateConfig config = {});
|
|
BrightnessDecision update(cv::Mat const& bgr);
|
|
private:
|
|
BrightnessGateConfig config_;
|
|
std::string state_{"INITIALIZING"};
|
|
int startup_count_{}, startup_dark_votes_{}, dark_streak_{}, bright_streak_{};
|
|
};
|
|
}
|