Skip to content

Commit 32d43b6

Browse files
author
Gin
committed
fix sandwich recipe detection test
1 parent c7b1fde commit 32d43b6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

SerialPrograms/Source/PokemonSV/Inference/Picnics/PokemonSV_SandwichRecipeDetector.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ bool SandwichRecipeSelectionWatcher::process_frame(const VideoSnapshot& frame){
127127
return num_arrows_found == 1;
128128
}
129129

130+
bool SandwichRecipeSelectionWatcher::detect(const ImageViewRGB32& frame){
131+
int num_arrows_found = 0;
132+
for(int i = 0; i < 6; i++){
133+
const bool found_arrow = m_arrow_watchers[i].detect(frame);
134+
if (found_arrow){
135+
m_selected_recipe = i;
136+
num_arrows_found++;
137+
}
138+
}
139+
return num_arrows_found == 1;
140+
}
141+
130142
}
131143
}
132144
}

SerialPrograms/Source/PokemonSV/Inference/Picnics/PokemonSV_SandwichRecipeDetector.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class SandwichRecipeSelectionWatcher : public VisualInferenceCallback{
5656
virtual void make_overlays(VideoOverlaySet& items) const override;
5757
virtual bool process_frame(const VideoSnapshot& frame) override;
5858

59+
// Whether it can detect the recipe selection on this frame.
60+
// Unlike `process_frame()` which relies on consecutive frames to give robust result,
61+
// this function uses only one frame.
62+
bool detect(const ImageViewRGB32& frame);
63+
5964
// Return which recipe cell is currented selected.
6065
// For cell order, see `SandwichRecipeNumberDetector`.
6166
// If no cell selection detected, return -1.

SerialPrograms/Source/Tests/PokemonSV_Tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int test_pokemonSV_SandwichRecipeDetector(const ImageViewRGB32& image, const std
184184
cerr << "Error: word " << words[words.size()-1] << " is wrong. Must be an integer in range [0, 6). " << endl;
185185
}
186186
SandwichRecipeSelectionWatcher selection_watcher;
187-
bool result = selection_watcher.process_frame({image.copy(), current_time()});
187+
bool result = selection_watcher.detect(image);
188188

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

0 commit comments

Comments
 (0)