Skip to content

Commit 470ff4f

Browse files
committed
Enforce X and Y buttons for MapDetector.
1 parent 6cd0937 commit 470ff4f

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
#include "PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h"
153153
#include "PokemonLZA/Inference/PokemonLZA_MoveEffectivenessSymbol.h"
154154
#include "PokemonLZA/Inference/PokemonLZA_MapIconDetector.h"
155+
#include "PokemonLZA/Inference/PokemonLZA_MapDetector.h"
155156

156157

157158

@@ -293,7 +294,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
293294

294295
// MoveEffectivenessSymbolMatcher::NoEffect();
295296

296-
#if 1
297+
#if 0
297298
MapIconDetector detector0(COLOR_RED, MapIconType::PokemonCenter, {0, 0, 1, 1}, &overlay);
298299
MapIconDetector detector1(COLOR_RED, MapIconType::Building, {0, 0, 1, 1}, &overlay);
299300
MapIconDetector detector2(COLOR_RED, MapIconType::BuildingFlyable, {0, 0, 1, 1}, &overlay);
@@ -315,11 +316,11 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
315316

316317

317318

318-
#if 0
319+
#if 1
319320

320321
auto snapshot = feed.snapshot();
321322

322-
MoveEffectivenessSymbolDetector detector(COLOR_RED, &overlay);
323+
MapDetector detector(COLOR_RED, &overlay);
323324
cout << detector.detect(snapshot) << endl;
324325
#endif
325326

SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_ButtonDetector.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,39 @@ class ButtonMatcher : public ImageMatch::WaterfillTemplateMatcher{
2727
// - min_height: candidate image min height if video stream is 4k
2828
ButtonMatcher(ButtonType type, size_t min_width, size_t min_height, double max_rmsd);
2929
static const ButtonMatcher& A(){
30-
static ButtonMatcher matcher(ButtonType::ButtonA, 60, 60, 70);
30+
static ButtonMatcher matcher(ButtonType::ButtonA, 50, 50, 70);
3131
return matcher;
3232
}
3333
static const ButtonMatcher& B(){
34-
static ButtonMatcher matcher(ButtonType::ButtonB, 60, 60, 70);
34+
static ButtonMatcher matcher(ButtonType::ButtonB, 50, 50, 70);
3535
return matcher;
3636
}
3737
static const ButtonMatcher& X(){
38-
static ButtonMatcher matcher(ButtonType::ButtonX, 60, 60, 70);
38+
static ButtonMatcher matcher(ButtonType::ButtonX, 50, 50, 70);
3939
return matcher;
4040
}
4141
static const ButtonMatcher& Y(){
42-
static ButtonMatcher matcher(ButtonType::ButtonY, 60, 60, 70);
42+
static ButtonMatcher matcher(ButtonType::ButtonY, 50, 50, 70);
4343
return matcher;
4444
}
4545
static const ButtonMatcher& L(){
46-
static ButtonMatcher matcher(ButtonType::ButtonL, 60, 60, 70);
46+
static ButtonMatcher matcher(ButtonType::ButtonL, 50, 50, 70);
4747
return matcher;
4848
}
4949
static const ButtonMatcher& R(){
50-
static ButtonMatcher matcher(ButtonType::ButtonR, 60, 60, 70);
50+
static ButtonMatcher matcher(ButtonType::ButtonR, 50, 50, 70);
5151
return matcher;
5252
}
5353
static const ButtonMatcher& Plus(){
54-
static ButtonMatcher matcher(ButtonType::ButtonPlus, 60, 60, 70);
54+
static ButtonMatcher matcher(ButtonType::ButtonPlus, 50, 50, 70);
5555
return matcher;
5656
}
5757
static const ButtonMatcher& Minus(){
58-
static ButtonMatcher matcher(ButtonType::ButtonMinus, 60, 60, 70);
58+
static ButtonMatcher matcher(ButtonType::ButtonMinus, 50, 50, 70);
5959
return matcher;
6060
}
6161
static const ButtonMatcher& Right(){
62-
static ButtonMatcher matcher(ButtonType::ButtonRight, 60, 60, 70);
62+
static ButtonMatcher matcher(ButtonType::ButtonRight, 50, 50, 70);
6363
return matcher;
6464
}
6565
static const ButtonMatcher& RightStickUpDown(){

SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_MapDetector.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,30 @@ MapDetector::MapDetector(Color color, VideoOverlay* overlay)
1919
{0.760730, 0.937023, 0.241416, 0.064885},
2020
overlay
2121
)
22+
, m_x_button(
23+
color,
24+
ButtonType::ButtonX,
25+
{0.004292, 0.208015, 0.028970, 0.049618},
26+
overlay
27+
)
28+
, m_y_button(
29+
color,
30+
ButtonType::ButtonY,
31+
{0.004292, 0.276718, 0.028970, 0.047710},
32+
overlay
33+
)
2234
{}
2335

2436
void MapDetector::make_overlays(VideoOverlaySet& items) const{
2537
m_b_button.make_overlays(items);
38+
m_x_button.make_overlays(items);
39+
m_y_button.make_overlays(items);
2640
}
2741

2842
bool MapDetector::detect(const ImageViewRGB32& screen){
29-
return m_b_button.detect(screen);
43+
return m_b_button.detect(screen)
44+
&& m_x_button.detect(screen)
45+
&& m_y_button.detect(screen);
3046
}
3147

3248

SerialPrograms/Source/PokemonLZA/Inference/PokemonLZA_MapDetector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class MapDetector : public StaticScreenDetector{
2727

2828
private:
2929
ButtonDetector m_b_button;
30+
ButtonDetector m_x_button;
31+
ButtonDetector m_y_button;
3032
};
3133

3234
class MapWatcher : public DetectorToFinder<MapDetector>{

0 commit comments

Comments
 (0)