Skip to content

Commit a6d0dae

Browse files
committed
Fix Switch 2 type detector again.
1 parent 83419c5 commit a6d0dae

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch2_BinarySliderDetector.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void BinarySliderDetector::make_overlays(VideoOverlaySet& items) const{
2828
items.add(m_color, m_box);
2929
}
3030

31-
std::vector<std::pair<bool, ImagePixelBox>> BinarySliderDetector::detect(const ImageViewRGB32& image) const{
31+
std::vector<std::pair<bool, ImagePixelBox>> BinarySliderDetector::detect(const ImageViewRGB32& screen) const{
3232
using namespace Kernels::Waterfill;
3333

3434
static ImageMatch::ExactImageMatcher LIGHT_OFF_CURSOR (RESOURCE_PATH() + "NintendoSwitch2/BinarySlider-Light-Off-Cursor.png");
@@ -40,7 +40,7 @@ std::vector<std::pair<bool, ImagePixelBox>> BinarySliderDetector::detect(const I
4040
static ImageMatch::ExactImageMatcher DARK_ON_CURSOR (RESOURCE_PATH() + "NintendoSwitch2/BinarySlider-Dark-On-Cursor.png");
4141
static ImageMatch::ExactImageMatcher DARK_ON_NOCURSOR (RESOURCE_PATH() + "NintendoSwitch2/BinarySlider-Dark-On-NoCursor.png");
4242

43-
ImageViewRGB32 region = extract_box_reference(image, m_box);
43+
ImageViewRGB32 region = extract_box_reference(screen, m_box);
4444

4545
std::vector<PackedBinaryMatrix> matrices = compress_rgb32_to_binary_range(
4646
region,
@@ -56,6 +56,7 @@ std::vector<std::pair<bool, ImagePixelBox>> BinarySliderDetector::detect(const I
5656

5757
std::vector<std::pair<bool, ImagePixelBox>> best;
5858

59+
// int c = 0;
5960
for (PackedBinaryMatrix& matrix : matrices){
6061
// cout << "-----------------" << endl;
6162
session->set_source(matrix);
@@ -69,6 +70,12 @@ std::vector<std::pair<bool, ImagePixelBox>> BinarySliderDetector::detect(const I
6970
if (aspect_ratio < 0.9 || aspect_ratio > 1.1){
7071
continue;
7172
}
73+
74+
double min_area = screen.total_pixels() * (3000. / (3840*2160));
75+
if ((double)object.area < min_area){
76+
continue;
77+
}
78+
7279
ImageViewRGB32 cropped = extract_box_reference(region, object);
7380

7481
double best_off_rmsd = 9999;
@@ -90,6 +97,8 @@ std::vector<std::pair<bool, ImagePixelBox>> BinarySliderDetector::detect(const I
9097
double best_rmsd = on ? best_on_rmsd : best_off_rmsd;
9198

9299
if (best_rmsd < 60){
100+
// cout << "rmsd = " << best_rmsd << endl;
101+
// cropped.save("slider-" + std::to_string(c) + "-" + std::to_string(sliders.size()) + ".png");
93102
sliders.emplace_back(on, object);
94103
}
95104

@@ -102,6 +111,8 @@ std::vector<std::pair<bool, ImagePixelBox>> BinarySliderDetector::detect(const I
102111
if (best.size() < sliders.size()){
103112
best = std::move(sliders);
104113
}
114+
115+
// c++;
105116
}
106117

107118
return best;

SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch2_BinarySliderDetector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BinarySliderDetector{
2222
BinarySliderDetector(Color color, const ImageFloatBox& box);
2323
void make_overlays(VideoOverlaySet& items) const;
2424

25-
std::vector<std::pair<bool, ImagePixelBox>> detect(const ImageViewRGB32& image) const;
25+
std::vector<std::pair<bool, ImagePixelBox>> detect(const ImageViewRGB32& screen) const;
2626

2727
private:
2828
Color m_color;

SerialPrograms/Source/NintendoSwitch/Programs/DateSpam/NintendoSwitch2_HomeToDateTime.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ void settings_to_date_time_Switch2_all_blind(
158158
ssf_issue_scroll(context, SSF_SCROLL_DOWN, unit);
159159
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 192ms, 2*unit, unit);
160160

161-
162161
switch (console_type){
163162
case ConsoleType::Switch2_FW19_International:
164163
ssf_issue_scroll(context, SSF_SCROLL_DOWN, 128ms, 2*unit, unit);
@@ -185,7 +184,6 @@ void settings_to_date_time_Switch2_all_blind(
185184
);
186185
}
187186

188-
189187
if (!to_date_change){
190188
// Triple up this A press to make sure it gets through.
191189
ssf_press_button(context, BUTTON_A, unit);

0 commit comments

Comments
 (0)