Skip to content

Commit da4a198

Browse files
committed
Fix PLA region navigation that broke during 4k video optimization.
1 parent 3295e80 commit da4a198

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

SerialPrograms/Source/PokemonLA/Inference/Map/PokemonLA_SelectedRegionDetector.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h"
1313
#include "PokemonLA_SelectedRegionDetector.h"
1414

15+
//#include <iostream>
16+
//using std::cout;
17+
//using std::endl;
18+
1519
namespace PokemonAutomation{
1620
namespace NintendoSwitch{
1721
namespace 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){

0 commit comments

Comments
 (0)