diff --git a/SerialPrograms/Source/CommonFramework/ImageMatch/ImageCropper.h b/SerialPrograms/Source/CommonFramework/ImageMatch/ImageCropper.h index 1c85aa0ad..3899e0ca4 100644 --- a/SerialPrograms/Source/CommonFramework/ImageMatch/ImageCropper.h +++ b/SerialPrograms/Source/CommonFramework/ImageMatch/ImageCropper.h @@ -22,7 +22,7 @@ namespace ImageMatch{ ImageViewRGB32 trim_image_alpha(const ImageViewRGB32& image, uint8_t alpha_threshold = 128); -// Filter out object from background. +// Find a crop of the object based on background color. // The pixels of the object are defined as is_object(pixel_color) == true. // Return the rectangle enclosing the object. ImagePixelBox enclosing_rectangle_with_pixel_filter(const ImageViewRGB32& image, const std::function& is_object); diff --git a/SerialPrograms/Source/PokemonSV/Inference/Picnics/PokemonSV_SandwichIngredientDetector.cpp b/SerialPrograms/Source/PokemonSV/Inference/Picnics/PokemonSV_SandwichIngredientDetector.cpp index 6b4381ad4..8e5d78817 100644 --- a/SerialPrograms/Source/PokemonSV/Inference/Picnics/PokemonSV_SandwichIngredientDetector.cpp +++ b/SerialPrograms/Source/PokemonSV/Inference/Picnics/PokemonSV_SandwichIngredientDetector.cpp @@ -160,7 +160,7 @@ bool SandwichPicksPageDetector::detect(const ImageViewRGB32& screen) const{ const SandwichFillingMatcher& SANDWICH_FILLING_MATCHER(){ - static SandwichFillingMatcher matcher; + static SandwichFillingMatcher matcher(100); return matcher; } SandwichFillingMatcher::SandwichFillingMatcher(double min_euclidean_distance) @@ -190,7 +190,7 @@ ImageRGB32 SandwichFillingMatcher::process_image(const ImageViewRGB32& image, Co const SandwichCondimentMatcher& SANDWICH_CONDIMENT_MATCHER(){ - static SandwichCondimentMatcher matcher; + static SandwichCondimentMatcher matcher(100); return matcher; } SandwichCondimentMatcher::SandwichCondimentMatcher(double min_euclidean_distance) diff --git a/SerialPrograms/Source/Tests/PokemonSV_Tests.cpp b/SerialPrograms/Source/Tests/PokemonSV_Tests.cpp index 75a9e2945..ddf4a000d 100644 --- a/SerialPrograms/Source/Tests/PokemonSV_Tests.cpp +++ b/SerialPrograms/Source/Tests/PokemonSV_Tests.cpp @@ -410,20 +410,13 @@ int test_pokemonSV_SandwichIngredientReader(const ImageViewRGB32& image, const s if (selected_ingredient == i){ // The icon matcher only works on the selected item, because we want to remove the yellow / orange background ImageMatch::ImageMatchResult results = reader.read_with_icon_matcher(image); - const std::string& target_slug = words[words.size() - 10 + i]; if (results.results.empty()){ cerr << "No ingredient detected via icon matcher" << endl; return 1; } - bool found = false; - for (const auto& match_candidate: results.results){ - if (match_candidate.second == target_slug){ - found = true; - break; - } - } - TEST_RESULT_COMPONENT_EQUAL(found, true, "image matcher : ingredient slot " + std::to_string(i)); + std::string best_match_icon_matcher = results.results.begin()->second; + TEST_RESULT_COMPONENT_EQUAL(best_match_icon_matcher, words[words.size() - 10 + i], "image matcher : ingredient slot " + std::to_string(i)); } { OCR::StringMatchResult results = reader.read_with_ocr(image, global_logger_command_line(), language);