File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
SerialPrograms/Source/PokemonLA/Inference/Map Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 1212#include " CommonTools/InferenceCallbacks/VisualInferenceCallback.h"
1313#include " PokemonLA_SelectedRegionDetector.h"
1414
15+ // #include <iostream>
16+ // using std::cout;
17+ // using std::endl;
18+
1519namespace PokemonAutomation {
1620namespace NintendoSwitch {
1721namespace PokemonLA {
@@ -42,6 +46,7 @@ class MapLocationDetector : public VisualInferenceCallback{
4246 reload_reference (frame.frame );
4347 }
4448
49+ MapRegion current_region = MapRegion::NONE;
4550 for (RegionState& region : m_regions){
4651 ImageViewRGB32 current = extract_box_reference (frame, region.box );
4752
@@ -52,11 +57,19 @@ class MapLocationDetector : public VisualInferenceCallback{
5257
5358 double rmsd = ImageMatch::pixel_RMSD (region.start , current);
5459 if (rmsd > 20 ){
55- m_current_region = region.region ;
56- return true ;
60+ if (current_region == MapRegion::NONE){
61+ current_region = region.region ;
62+ }else {
63+ // Multiple large diffs. Frame isn't stable.
64+ // cout << "Multiple diffs: " << rmsd << endl;
65+ reload_reference (frame.frame );
66+ return false ;
67+ }
5768 }
5869 }
59- return false ;
70+
71+ m_current_region = current_region;
72+ return current_region != MapRegion::NONE;
6073 }
6174
6275 void reload_reference (std::shared_ptr<const ImageRGB32> screen){
You can’t perform that action at this time.
0 commit comments