Skip to content

Commit 03274d0

Browse files
committed
Fix HomeMenuDetector.
1 parent 922f6a7 commit 03274d0

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,13 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
265265
VideoOverlaySet overlays(overlay);
266266

267267

268+
HomeMenuDetector detector(console);
269+
detector.make_overlays(overlays);
270+
271+
268272

269273

274+
#if 0
270275
// auto screenshot = feed.snapshot();
271276

272277
PokemonLGPE::BattleArrowWatcher detector(COLOR_RED, {0.004251, 0.638941, 0.062699, 0.115312});
@@ -276,7 +281,7 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
276281
cout << detector.process_frame(feed.snapshot()) << endl;
277282
scope.wait_for(100ms);
278283
}
279-
284+
#endif
280285

281286

282287

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_ConsoleTypeDetector.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
88
#include "CommonFramework/ImageTools/ImageStats.h"
99
#include "NintendoSwitch_ConsoleTypeDetector.h"
10-
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
10+
//#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1111
#include "NintendoSwitch/Programs/NintendoSwitch_GameEntry.h"
12-
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1312

1413
//#include <iostream>
1514
//using std::cout;
@@ -22,12 +21,14 @@ namespace NintendoSwitch{
2221
ConsoleTypeDetector_Home::ConsoleTypeDetector_Home(ConsoleHandle& console, Color color)
2322
: m_console(console)
2423
, m_color(color)
25-
, m_bottom_line(0.10, 0.88, 0.80, 0.03)
24+
, m_bottom_line(0.20, 0.88, 0.60, 0.03)
2625
, m_last(ConsoleType::Unknown)
2726
{}
2827
void ConsoleTypeDetector_Home::make_overlays(VideoOverlaySet& items) const{
2928
ConsoleType known_state = m_console.state().console_type();
30-
if (known_state != ConsoleType::Unknown){
29+
if (known_state != ConsoleType::Unknown &&
30+
m_console.state().console_type_confirmed()
31+
){
3132
return;
3233
}
3334
items.add(m_color, m_bottom_line);

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_HomeMenuDetector.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ HomeMenuDetector::HomeMenuDetector(ConsoleHandle& console, Color color)
2222
: m_color(color)
2323
, m_console_type(console, color)
2424
, m_top(0.510223, 0.019835, 0.441450, 0.034711)
25+
// , m_iconrow_left(0.02, 0.70, 0.13, 0.15)
26+
, m_iconrow_right(0.85, 0.70, 0.13, 0.15)
27+
, m_iconrow_icons(0.20, 0.70, 0.60, 0.15)
2528
, m_bottom_row(0.10, 0.92, 0.10, 0.05)
2629
, m_bottom_icons(0.70, 0.92, 0.28, 0.05)
27-
, m_bottom_left(0.02, 0.70, 0.15, 0.15)
28-
, m_bottom_right(0.83, 0.70, 0.15, 0.15)
29-
, m_bottom_middle(0.20, 0.70, 0.60, 0.15)
3030
, m_user_icons(0.05, 0.05, 0.2, 0.08)
3131
, m_game_slot(0.08, 0.25, 0.10, 0.38)
3232
{}
3333
void HomeMenuDetector::make_overlays(VideoOverlaySet& items) const{
3434
m_console_type.make_overlays(items);
3535
items.add(m_color, m_top);
36+
// items.add(m_color, m_iconrow_left);
37+
items.add(m_color, m_iconrow_right);
38+
items.add(m_color, m_iconrow_icons);
3639
items.add(m_color, m_bottom_row);
3740
items.add(m_color, m_bottom_icons);
38-
items.add(m_color, m_bottom_left);
39-
items.add(m_color, m_bottom_right);
40-
items.add(m_color, m_bottom_middle);
4141
items.add(m_color, m_user_icons);
4242
items.add(m_color, m_game_slot);
4343
}
@@ -92,44 +92,44 @@ bool HomeMenuDetector::detect_only(const ImageViewRGB32& screen){
9292
return false;
9393
}
9494

95-
ImageStats stats_bottom_left = image_stats(extract_box_reference(screen, m_bottom_left));
96-
ImageStats stats_bottom_right = image_stats(extract_box_reference(screen, m_bottom_right));
95+
// ImageStats stats_bottom_left = image_stats(extract_box_reference(screen, m_bottom_row));
96+
ImageStats stats_bottom_right = image_stats(extract_box_reference(screen, m_iconrow_right));
9797
// cout << stats_bottom_left.average << stats_bottom_left.stddev << endl;
9898
// cout << stats_bottom_right.average << stats_bottom_right.stddev << endl;
9999
if (white){
100-
if (!is_white(stats_bottom_left) || !is_white(stats_bottom_right)){
100+
if (!is_white(stats_bottom_row) || !is_white(stats_bottom_right)){
101101
// cout << "asdf" << endl;
102102
return false;
103103
}
104104
}else{
105-
if (!is_grey(stats_bottom_left, 0, 200) || !is_grey(stats_bottom_right, 0, 200)){
105+
if (!is_grey(stats_bottom_row, 0, 200) || !is_grey(stats_bottom_right, 0, 200)){
106106
// cout << "qwer" << endl;
107107
return false;
108108
}
109109
}
110110

111-
ImageStats stats_bottom_middle = image_stats(extract_box_reference(screen, m_bottom_middle));
111+
ImageStats stats_bottom_middle = image_stats(extract_box_reference(screen, m_iconrow_icons));
112112
if (stats_bottom_middle.stddev.sum() < 50){
113113
return false;
114114
}
115115

116-
// cout << euclidean_distance(stats_bottom_row.average, stats_bottom_left.average) << endl;
117-
if (euclidean_distance(stats_bottom_row.average, stats_bottom_left.average) > 20){
118-
// cout << "qwer = " << euclidean_distance(stats_bottom_row.average, stats_bottom_left.average) << endl;
116+
// cout << euclidean_distance(stats_bottom_row.average, stats_bottom_row.average) << endl;
117+
if (euclidean_distance(stats_bottom_row.average, stats_bottom_row.average) > 20){
118+
// cout << "qwer = " << euclidean_distance(stats_bottom_row.average, stats_bottom_row.average) << endl;
119119
return false;
120120
}
121121
// cout << euclidean_distance(stats_bottom_row.average, stats_bottom_right.average) << endl;
122122
if (euclidean_distance(stats_bottom_row.average, stats_bottom_right.average) > 20){
123123
// cout << "asdf" << endl;
124124
return false;
125125
}
126-
// cout << euclidean_distance(stats_bottom_left.average, stats_bottom_left.average) << endl;
127-
if (euclidean_distance(stats_bottom_left.average, stats_bottom_right.average) > 20){
126+
// cout << euclidean_distance(stats_bottom_row.average, stats_bottom_row.average) << endl;
127+
if (euclidean_distance(stats_bottom_row.average, stats_bottom_right.average) > 20){
128128
// cout << "zxcv" << endl;
129129
return false;
130130
}
131-
// cout << euclidean_distance(stats_top.average, stats_bottom_left.average) << endl;
132-
if (euclidean_distance(stats_top.average, stats_bottom_left.average) > 20){
131+
// cout << euclidean_distance(stats_top.average, stats_bottom_row.average) << endl;
132+
if (euclidean_distance(stats_top.average, stats_bottom_row.average) > 20){
133133
// cout << "xcvb" << endl;
134134
return false;
135135
}

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_HomeMenuDetector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class HomeMenuDetector : public StaticScreenDetector{
3131
Color m_color;
3232
ConsoleTypeDetector_Home m_console_type;
3333
ImageFloatBox m_top;
34+
// ImageFloatBox m_iconrow_left;
35+
ImageFloatBox m_iconrow_right;
36+
ImageFloatBox m_iconrow_icons;
3437
ImageFloatBox m_bottom_row;
3538
ImageFloatBox m_bottom_icons;
36-
ImageFloatBox m_bottom_left;
37-
ImageFloatBox m_bottom_right;
38-
ImageFloatBox m_bottom_middle;
3939
ImageFloatBox m_user_icons;
4040
ImageFloatBox m_game_slot;
4141
};

0 commit comments

Comments
 (0)