Skip to content

Commit

Permalink
fix sandwich recipe detection test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gin committed Dec 5, 2023
1 parent c7b1fde commit 32d43b6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ bool SandwichRecipeSelectionWatcher::process_frame(const VideoSnapshot& frame){
return num_arrows_found == 1;
}

bool SandwichRecipeSelectionWatcher::detect(const ImageViewRGB32& frame){
int num_arrows_found = 0;
for(int i = 0; i < 6; i++){
const bool found_arrow = m_arrow_watchers[i].detect(frame);
if (found_arrow){
m_selected_recipe = i;
num_arrows_found++;
}
}
return num_arrows_found == 1;
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class SandwichRecipeSelectionWatcher : public VisualInferenceCallback{
virtual void make_overlays(VideoOverlaySet& items) const override;
virtual bool process_frame(const VideoSnapshot& frame) override;

// Whether it can detect the recipe selection on this frame.
// Unlike `process_frame()` which relies on consecutive frames to give robust result,
// this function uses only one frame.
bool detect(const ImageViewRGB32& frame);

// Return which recipe cell is currented selected.
// For cell order, see `SandwichRecipeNumberDetector`.
// If no cell selection detected, return -1.
Expand Down
2 changes: 1 addition & 1 deletion SerialPrograms/Source/Tests/PokemonSV_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int test_pokemonSV_SandwichRecipeDetector(const ImageViewRGB32& image, const std
cerr << "Error: word " << words[words.size()-1] << " is wrong. Must be an integer in range [0, 6). " << endl;
}
SandwichRecipeSelectionWatcher selection_watcher;
bool result = selection_watcher.process_frame({image.copy(), current_time()});
bool result = selection_watcher.detect(image);

TEST_RESULT_COMPONENT_EQUAL(result, true, "SandwichRecipeSelectionWatcher::process_frame() result");

Expand Down

0 comments on commit 32d43b6

Please sign in to comment.