Skip to content

Commit fcd2374

Browse files
committed
Improve reliability of Switch 2 type detection.
1 parent 3c24b16 commit fcd2374

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch2_BinarySliderDetector.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#include "CommonTools/ImageMatch/ExactImageMatcher.h"
1212
#include "NintendoSwitch2_BinarySliderDetector.h"
1313

14+
//#include <iostream>
15+
//using std::cout;
16+
//using std::endl;
17+
1418
namespace PokemonAutomation{
1519
namespace NintendoSwitch{
1620

@@ -57,23 +61,23 @@ std::vector<std::pair<bool, ImagePixelBox>> BinarySliderDetector::detect(const I
5761
best_off_rmsd = std::min(best_off_rmsd, LIGHT_OFF_NOCURSOR.rmsd(cropped));
5862
best_off_rmsd = std::min(best_off_rmsd, DARK_OFF_CURSOR.rmsd(cropped));
5963
best_off_rmsd = std::min(best_off_rmsd, DARK_OFF_NOCURSOR.rmsd(cropped));
60-
if (best_off_rmsd < 40){
61-
ret.emplace_back(false, object);
62-
continue;
63-
}
6464

6565
double best_on_rmsd = 9999;
6666
best_on_rmsd = std::min(best_on_rmsd, LIGHT_ON_CURSOR.rmsd(cropped));
6767
best_on_rmsd = std::min(best_on_rmsd, LIGHT_ON_NOCURSOR.rmsd(cropped));
6868
best_on_rmsd = std::min(best_on_rmsd, DARK_ON_CURSOR.rmsd(cropped));
6969
best_on_rmsd = std::min(best_on_rmsd, DARK_ON_NOCURSOR.rmsd(cropped));
70-
if (best_on_rmsd < 40){
71-
ret.emplace_back(true, object);
72-
continue;
73-
}
7470

7571
// cout << "best_off_rmsd = " << best_off_rmsd << endl;
7672
// cout << "best_on_rmsd = " << best_on_rmsd << endl;
73+
74+
bool on = best_on_rmsd < best_off_rmsd;
75+
double best = on ? best_on_rmsd : best_off_rmsd;
76+
77+
if (best < 60){
78+
ret.emplace_back(on, object);
79+
}
80+
7781
}
7882

7983
return ret;

0 commit comments

Comments
 (0)