Skip to content

Commit

Permalink
tighten sandwich ingredient background check
Browse files Browse the repository at this point in the history
  • Loading branch information
Gin committed Sep 15, 2023
1 parent 2956936 commit 88db677
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool(Color)>& is_object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 2 additions & 9 deletions SerialPrograms/Source/Tests/PokemonSV_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 88db677

Please sign in to comment.