Skip to content

Commit c166067

Browse files
author
Gin
committed
fix flat white dialog detector
1 parent 39db9c5 commit c166067

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

SerialPrograms/Source/CommonTools/Images/SolidColorTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ bool is_solid(
7373
){
7474
double stddev = stats.stddev.sum();
7575
if (stddev > max_stddev_sum){
76-
// cout << "bad stddev = " << stddev << endl;
76+
// cout << "bad stddev = " << stddev << endl;
7777
return false;
7878
}
7979

8080
double average = stats.average.sum();
8181
FloatPixel actual = stats.average / average;
8282
double distance = euclidean_distance(actual, expected_color_ratio);
83-
// cout << "actual color ratio " << actual << endl;
84-
// cout << "distance = " << distance << endl;
83+
// cout << "actual color ratio " << actual << endl;
84+
// cout << "distance = " << distance << endl;
8585

8686
return distance <= max_euclidean_distance;
8787
}

SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_DialogDetector.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
1515
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
1616

17-
//#include <iostream>
18-
//using std::cout;
19-
//using std::endl;
17+
// #include <iostream>
18+
// using std::cout;
19+
// using std::endl;
2020

2121
namespace PokemonAutomation{
2222
namespace NintendoSwitch{
@@ -219,7 +219,7 @@ void FlatWhiteDialogDetector::make_overlays(VideoOverlaySet& items) const{
219219
items.add(m_color, m_arrow_box);
220220
}
221221
bool FlatWhiteDialogDetector::detect(const ImageViewRGB32& screen){
222-
if (!is_white(extract_box_reference(screen, m_top), 500, 20)){
222+
if (!is_white(extract_box_reference(screen, m_top), 500.0, 20.0)){
223223
m_last_detected_box.reset();
224224
return false;
225225
}

SerialPrograms/Source/Tests/PokemonLZA_Tests.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,19 @@ int test_pokemonZLA_NormalDialogBoxDetector(const ImageViewRGB32& image, bool ta
3838
auto& logger = global_logger_command_line();
3939
auto overlay = DummyVideoOverlay();
4040
const bool stop_on_detected = true;
41-
NormalDialogDetector detector(logger, overlay, stop_on_detected);
41+
NormalDialogDetector detector(logger, overlay, stop_on_detected);
4242
bool result = detector.process_frame(image, current_time());
4343
TEST_RESULT_EQUAL(result, target);
4444
return 0;
4545
}
4646

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

4856
}

SerialPrograms/Source/Tests/PokemonLZA_Tests.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020

2121

2222
int test_pokemonZLA_NormalDialogBoxDetector(const ImageViewRGB32& image, bool target);
23-
23+
24+
int test_pokemonLZA_FlatWhiteDialogDetector(const ImageViewRGB32& image, bool target);
25+
2426
}
25-
27+
2628
#endif
2729

SerialPrograms/Source/Tests/TestMap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ const std::map<std::string, TestFunction> TEST_MAP = {
289289
{"PokemonSV_SandwichPlateDetector", std::bind(image_words_detector_helper, test_pokemonSV_SandwichPlateDetector, _1)},
290290
{"PokemonSV_RecentlyBattledDetector", std::bind(image_bool_detector_helper, test_pokemonSV_RecentlyBattledDetector, _1)},
291291
{"PokemonLZA_NormalDialogBoxDetector", std::bind(image_bool_detector_helper, test_pokemonZLA_NormalDialogBoxDetector, _1)},
292+
{"PokemonLZA_FlatWhiteDialogDetector", std::bind(image_bool_detector_helper, test_pokemonLZA_FlatWhiteDialogDetector, _1)},
292293
};
293294

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

0 commit comments

Comments
 (0)