@@ -54,11 +54,6 @@ bool YCommMenuDetector::process_frame(const ImageViewRGB32& frame, WallClock tim
5454}
5555
5656
57- namespace {
58-
59- ImageFloatBox YCOMM_ICON_BOX{0.007 , 0.944 , 0.032 , 0.054 };
60-
61- }
6257
6358class YCommIconMatcher : public ImageMatch ::WaterfillTemplateMatcher{
6459public:
@@ -85,36 +80,52 @@ const YCommIconMatcher& YCommIconMatcher::instance(){
8580}
8681
8782
88- YCommIconDetector::YCommIconDetector (bool is_on)
89- : VisualInferenceCallback(" YCommIconDetector" )
83+ YCommIconDetector::YCommIconDetector (Color color, bool is_on)
84+ : m_color(color)
85+ , m_icon(0.007 , 0.944 , 0.032 , 0.054 )
86+ , m_left(0.004362 , 0.961165 , 0.007634 , 0.025243 )
87+ , m_right(0.038000 , 0.961165 , 0.007634 , 0.025243 )
9088 , m_is_on(is_on)
9189{}
9290
9391void YCommIconDetector::make_overlays (VideoOverlaySet& items) const {
94- items.add (COLOR_RED, YCOMM_ICON_BOX);
92+ items.add (COLOR_RED, m_icon);
93+ items.add (COLOR_RED, m_left);
94+ items.add (COLOR_RED, m_right);
9595}
9696
97- bool YCommIconDetector::process_frame (const ImageViewRGB32& frame, WallClock timestamp ){
97+ bool YCommIconDetector::detect (const ImageViewRGB32& screen ){
9898
9999 const std::vector<std::pair<uint32_t , uint32_t >> filters = {
100100 {combine_rgb (0 , 0 , 150 ), combine_rgb (100 , 100 , 255 )},
101101 {combine_rgb (0 , 0 , 150 ), combine_rgb (127 , 127 , 255 )},
102102 {combine_rgb (0 , 0 , 150 ), combine_rgb (191 , 191 , 255 )},
103103 };
104104
105- const size_t min_size = (size_t )(350 . * frame .total_pixels () / (1920 * 1080 .));
105+ const size_t min_size = (size_t )(350 . * screen .total_pixels () / (1920 * 1080 .));
106106
107- const bool detected = match_template_by_waterfill (
108- frame .size (),
109- extract_box_reference (frame, YCOMM_ICON_BOX),
107+ if ( match_template_by_waterfill (
108+ screen .size (),
109+ extract_box_reference (screen, m_icon),
110110 YCommIconMatcher::instance (),
111111 filters,
112112 {min_size, SIZE_MAX},
113113 120 ,
114114 [](Kernels::Waterfill::WaterfillObject& object) -> bool { return true ; }
115- );
115+ )){
116+ return m_is_on;
117+ }
118+
119+ ImageStats left = image_stats (extract_box_reference (screen, m_left));
120+ if (!is_solid (left, {0.0410557 , 0.211144 , 0.747801 }, 0.20 )){
121+ return !m_is_on;
122+ }
123+ ImageStats right = image_stats (extract_box_reference (screen, m_right));
124+ if (!is_solid (right, {0.0410557 , 0.211144 , 0.747801 }, 0.20 )){
125+ return !m_is_on;
126+ }
116127
117- return m_is_on ? detected : !detected ;
128+ return m_is_on;
118129}
119130
120131
0 commit comments