@@ -133,12 +133,12 @@ const static ImageFloatBox DIALOG_ARROW_BOX{0.727, 0.868, 0.037, 0.086};
133133
134134// detect the white arrow in blue dialog box and transparent battle dialog box
135135bool detect_white_arrow (const ImageViewRGB32& screen, PokemonAutomation::ImageFloatBox& found_box){
136- double screen_rel_size = (screen.height () / 1080.0 );
137- double screen_rel_size_2 = screen_rel_size * screen_rel_size;
136+ const double screen_rel_size = (screen.height () / 1080.0 );
137+ const double screen_rel_size_2 = screen_rel_size * screen_rel_size;
138138
139- double min_area_1080p = 150.0 ;
140- double rmsd_threshold = 120.0 ;
141- size_t min_area = size_t (screen_rel_size_2 * min_area_1080p);
139+ const double min_area_1080p = 150.0 ;
140+ const double rmsd_threshold = 120.0 ;
141+ const size_t min_area = size_t (screen_rel_size_2 * min_area_1080p);
142142
143143 const std::vector<std::pair<uint32_t , uint32_t >> FILTERS = {
144144 {0xffc0c0c0 , 0xffffffff },
@@ -194,107 +194,6 @@ bool detect_blue_arrow(const ImageViewRGB32& screen, PokemonAutomation::ImageFlo
194194
195195
196196
197-
198- NormalDialogDetector::NormalDialogDetector (Logger& logger, VideoOverlay& overlay, bool stop_on_detected)
199- : VisualInferenceCallback(" NormalDialogDetector" )
200- , m_stop_on_detected(stop_on_detected)
201- , m_detected(false )
202- , m_title_green_line_box(0.224 , 0.727 , 0.016 , 0.056 )
203- {}
204- void NormalDialogDetector::make_overlays (VideoOverlaySet& items) const {
205- items.add (COLOR_RED, m_title_green_line_box);
206- items.add (COLOR_RED, DIALOG_ARROW_BOX);
207- }
208- bool NormalDialogDetector::process_frame (const ImageViewRGB32& frame, WallClock timestamp){
209- const double screen_rel_size = (frame.height () / 1080.0 );
210- const double screen_rel_size_2 = screen_rel_size * screen_rel_size;
211-
212- bool found_green_title_line = false ;
213- bool found_black_arrow = false ;
214-
215- // Example green pixels from screenshots:
216- // 194,230,70
217- // 212,235,127
218- // 176,212,62
219- const std::vector<std::pair<uint32_t , uint32_t >> green_line_filters = {
220- {combine_rgb (160 ,200 ,55 ), combine_rgb (220 , 240 , 130 )}
221- };
222-
223- const double min_green_line_size_1080P = 100.0 ;
224- const double green_line_rmsd_threshold = 50.0 ;
225- const size_t min_green_line_size = size_t (screen_rel_size_2 * min_green_line_size_1080P);
226- match_template_by_waterfill (
227- frame.size (),
228- extract_box_reference (frame, m_title_green_line_box),
229- DialogTitleGreenLineMatcher::instance (),
230- green_line_filters,
231- {min_green_line_size, SIZE_MAX},
232- green_line_rmsd_threshold,
233- [&](Kernels::Waterfill::WaterfillObject& object) -> bool {
234- found_green_title_line = true ;
235- return true ;
236- }
237- );
238-
239- // Example green pixels from screenshots:
240- // [37,34,6] [20,15,55]
241- // [39,42,58] [60,56,74] [50,49,63]
242- const std::vector<std::pair<uint32_t , uint32_t >> black_arrow_filters = {
243- {combine_rgb (0 ,0 ,0 ), combine_rgb (100 , 100 , 100 )}
244- };
245-
246- const double min_black_arrow_size_1080P = 150.0 ;
247- const double black_arrow_rmsd_threshold = 120.0 ;
248- const size_t min_black_arrow_size = size_t (screen_rel_size_2 * min_black_arrow_size_1080P);
249- match_template_by_waterfill (
250- frame.size (),
251- extract_box_reference (frame, DIALOG_ARROW_BOX),
252- DialogBlackArrowMatcher::instance (),
253- black_arrow_filters,
254- {min_black_arrow_size, SIZE_MAX},
255- black_arrow_rmsd_threshold,
256- [&](Kernels::Waterfill::WaterfillObject& object) -> bool {
257- found_black_arrow = true ;
258- return true ;
259- }
260- );
261-
262- bool is_dialog_box = found_green_title_line & found_black_arrow;
263-
264- if (is_dialog_box){
265- m_detected.store (is_dialog_box);
266- }
267-
268- return is_dialog_box & m_stop_on_detected;
269-
270-
271- // size_t hits = 0;
272-
273- // const ImageStats title_top = image_stats(extract_box_reference(frame, m_title_top));
274- // const ImageStats title_bottom = image_stats(extract_box_reference(frame, m_title_bottom));
275- // const ImageStats title_left = image_stats(extract_box_reference(frame, m_title_left));
276- // const ImageStats title_right = image_stats(extract_box_reference(frame, m_title_right));
277-
278- // ImageStats top_white = image_stats(extract_box_reference(frame, m_top_white));
279- // hits += is_white(top_white, 480, 30) ? 1 : 0;
280-
281- // ImageStats bottom_white = image_stats(extract_box_reference(frame, m_bottom_white));
282- // hits += is_white(bottom_white, 480, 30) ? 1 : 0;
283-
284- // ImageStats left_white = image_stats(extract_box_reference(frame, m_left_white));
285- // hits += is_white(left_white, 480, 30) ? 1 : 0;
286-
287- // ImageStats right_white = image_stats(extract_box_reference(frame, m_right_white));
288- // hits += is_white(right_white, 480, 30) ? 1 : 0;
289-
290- // bool detected = hits == 5;
291- // m_detected.store(detected, std::memory_order_release);
292-
293- // return detected && m_stop_on_detected;
294- }
295-
296-
297-
298197FlatWhiteDialogDetector::FlatWhiteDialogDetector (Color color, VideoOverlay* overlay)
299198 : m_color(color)
300199 , m_overlay(overlay)
0 commit comments