diff --git a/SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp b/SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp index 6ff30ca52..fd43b5d83 100644 --- a/SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp +++ b/SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp @@ -83,7 +83,8 @@ bool is_selection_arrow(const ImageViewRGB32& image, const WaterfillObject& obje } std::vector find_selection_arrows(const ImageViewRGB32& image, size_t min_area){ if (PreloadSettings::debug().IMAGE_TEMPLATE_MATCHING){ - std::cout << "Match SwSh selection arrow by waterfill, size range (" << min_area << ", SIZE_MAX)" << std::endl; + std::cout << "Match SwSh selection arrow by waterfill, size range (" << min_area << ", SIZE_MAX) " + << "input image size " << image.width() << " x " << image.height() << std::endl; } PackedBinaryMatrix matrix = compress_rgb32_to_binary_max(image, 63, 63, 63); auto session = make_WaterfillSession(matrix); @@ -91,7 +92,9 @@ std::vector find_selection_arrows(const ImageViewRGB32& image, si std::vector ret; WaterfillObject object; while (finder->find_next(object, true)){ -// cout << object.min_x << "-" << object.max_x << ", " << object.min_y << "-" << object.max_y << endl; + if (PreloadSettings::debug().IMAGE_TEMPLATE_MATCHING){ + std::cout << "Found object: " << object.min_x << "-" << object.max_x << ", " << object.min_y << "-" << object.max_y << std::endl; + } if (is_selection_arrow(image, object)){ ret.emplace_back(object); } diff --git a/SerialPrograms/Source/Tests/PokemonSwSh_Tests.cpp b/SerialPrograms/Source/Tests/PokemonSwSh_Tests.cpp index 954b56783..9b40d92d1 100644 --- a/SerialPrograms/Source/Tests/PokemonSwSh_Tests.cpp +++ b/SerialPrograms/Source/Tests/PokemonSwSh_Tests.cpp @@ -30,6 +30,12 @@ using std::endl; namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSwSh{ +std::vector find_selection_arrows(const ImageViewRGB32& image, size_t min_area); +} +} + using namespace NintendoSwitch::PokemonSwSh; int test_pokemonSwSh_YCommMenuDetector(const ImageViewRGB32& image, bool target){ @@ -125,4 +131,13 @@ int test_pokemonSwSh_BoxGenderDetector(const ImageViewRGB32& image, int target){ return 0; } +int test_pokemonSwSh_SelectionArrowFinder(const ImageViewRGB32& image, int target){ + std::vector boxes = find_selection_arrows(image, 10); + for(const auto& box : boxes){ + std::cout << "Found box: " << box.min_x << " " << box.max_x << " " << box.min_y << " " << box.max_y << std::endl; + } + TEST_RESULT_EQUAL(boxes.size(), (size_t)target); + return 0; +} + } diff --git a/SerialPrograms/Source/Tests/PokemonSwSh_Tests.h b/SerialPrograms/Source/Tests/PokemonSwSh_Tests.h index af50469e7..ab46d6506 100644 --- a/SerialPrograms/Source/Tests/PokemonSwSh_Tests.h +++ b/SerialPrograms/Source/Tests/PokemonSwSh_Tests.h @@ -38,6 +38,8 @@ int test_pokemonSwSh_BoxShinySymbolDetector(const ImageViewRGB32& image, bool ta int test_pokemonSwSh_BoxGenderDetector(const ImageViewRGB32& image, int target); +int test_pokemonSwSh_SelectionArrowFinder(const ImageViewRGB32& image, int target); + } #endif diff --git a/SerialPrograms/Source/Tests/TestMap.cpp b/SerialPrograms/Source/Tests/TestMap.cpp index 26c99bcf4..0f27fa2b7 100644 --- a/SerialPrograms/Source/Tests/TestMap.cpp +++ b/SerialPrograms/Source/Tests/TestMap.cpp @@ -240,6 +240,7 @@ const std::map TEST_MAP = { {"PokemonSwSh_BlackDialogBoxDetector", std::bind(image_bool_detector_helper, test_pokemonSwSh_BlackDialogBoxDetector, _1)}, {"PokemonSwSh_BoxShinySymbolDetector", std::bind(image_bool_detector_helper, test_pokemonSwSh_BoxShinySymbolDetector, _1)}, {"PokemonSwSh_BoxGenderDetector", std::bind(image_int_detector_helper, test_pokemonSwSh_BoxGenderDetector, _1)}, + {"PokemonSwSh_SelectionArrowFinder", std::bind(image_int_detector_helper, test_pokemonSwSh_SelectionArrowFinder, _1)}, {"PokemonLA_BattleMenuDetector", std::bind(image_bool_detector_helper, test_pokemonLA_BattleMenuDetector, _1)}, {"PokemonLA_BattlePokemonSwitchDetector", std::bind(image_bool_detector_helper, test_pokemonLA_BattlePokemonSwitchDetector, _1)}, {"PokemonLA_TransparentDialogueDetector", std::bind(image_bool_detector_helper, test_pokemonLA_TransparentDialogueDetector, _1)},