Skip to content

Commit 99baf65

Browse files
committed
fix white dialog detection
1 parent 3c57ec8 commit 99baf65

4 files changed

Lines changed: 21 additions & 10 deletions

File tree

SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ bool WhiteDialogDetector::detect(const ImageViewRGB32& screen){
3939
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box);
4040
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
4141
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
42-
if (is_solid(right_image, { 0.333333, 0.333333, 0.333333 })
43-
&& is_solid(top_image, { 0.333333, 0.333333, 0.333333 })
44-
&& is_solid(bottom_image, { 0.333333, 0.333333, 0.333333 })
42+
if (is_white(right_image)
43+
&& is_white(top_image)
44+
&& is_white(bottom_image)
4545
){
4646
return true;
4747
}
@@ -81,9 +81,9 @@ bool AdvanceWhiteDialogDetector::detect(const ImageViewRGB32& screen){
8181
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
8282
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
8383

84-
if (is_solid(right_image, { 0.333333, 0.333333, 0.333333 })
85-
&& is_solid(top_image, { 0.333333, 0.333333, 0.333333 })
86-
&& is_solid(bottom_image, { 0.333333, 0.333333, 0.333333 })
84+
if (is_white(right_image)
85+
&& is_white(top_image)
86+
&& is_white(bottom_image)
8787
&& (stats.average.r > stats.average.b + 180)
8888
&& (stats.average.r > stats.average.g + 180)
8989
)
@@ -110,10 +110,10 @@ bool SelectionDialogDetector::detect(const ImageViewRGB32& screen){
110110
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
111111
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
112112
ImageViewRGB32 selection_image = extract_box_reference(screen, m_selection_box);
113-
if (is_solid(right_image, { 0.333333, 0.333333, 0.333333 })
114-
&& is_solid(top_image, { 0.333333, 0.333333, 0.333333 })
115-
&& is_solid(bottom_image, { 0.333333, 0.333333, 0.333333 })
116-
&& is_solid(selection_image, { 0.333333, 0.333333, 0.333333 })
113+
if (is_white(right_image)
114+
&& is_white(top_image)
115+
&& is_white(bottom_image)
116+
&& is_white(selection_image)
117117
){
118118
return true;
119119
}

SerialPrograms/Source/Tests/PokemonFRLG_Tests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@ int test_pokemonFRLG_ShinySymbolDetector(const ImageViewRGB32& image, bool targe
4343
return 0;
4444
}
4545

46+
int test_pokemonFRLG_SelectionDialogDetector(const ImageViewRGB32& image, bool target){
47+
auto overlay = DummyVideoOverlay();
48+
SelectionDialogDetector detector(COLOR_RED);
49+
bool result = detector.detect(image);
50+
TEST_RESULT_EQUAL(result, target);
51+
return 0;
52+
}
53+
4654
}

SerialPrograms/Source/Tests/PokemonFRLG_Tests.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ int test_pokemonFRLG_AdvanceWhiteDialogDetector(const ImageViewRGB32& image, boo
2121

2222
int test_pokemonFRLG_ShinySymbolDetector(const ImageViewRGB32& image, bool target);
2323

24+
int test_pokemonFRLG_SelectionDialogDetector(const ImageViewRGB32& image, bool target);
25+
2426
}
2527

2628
#endif

SerialPrograms/Source/Tests/TestMap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ const std::map<std::string, TestFunction> TEST_MAP = {
311311
{"PokemonLZA_DonutBerriesReader", test_pokemonLZA_DonutBerriesReader},
312312
{"PokemonFRLG_AdvanceWhiteDialogDetector", std::bind(image_bool_detector_helper, test_pokemonFRLG_AdvanceWhiteDialogDetector, _1)},
313313
{"PokemonFRLG_ShinySymbolDetector", std::bind(image_bool_detector_helper, test_pokemonFRLG_ShinySymbolDetector, _1)},
314+
{"PokemonFRLG_SelectionDialogDetector", std::bind(image_bool_detector_helper, test_pokemonFRLG_SelectionDialogDetector, _1)},
314315
};
315316

316317
TestFunction find_test_function(const std::string& test_space, const std::string& test_name){

0 commit comments

Comments
 (0)