Skip to content

Commit 8e2f46f

Browse files
committed
Improve Y-COMM symbol detector.
1 parent 1507670 commit 8e2f46f

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

SerialPrograms/Source/CommonTools/Images/WaterfillUtilities.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "WaterfillUtilities.h"
1919

2020
#include <iostream>
21+
//using std::cout;
22+
//using std::endl;
2123

2224

2325
namespace PokemonAutomation{
@@ -96,6 +98,7 @@ bool match_template_by_waterfill(
9698
std::cout << ")" << std::endl;
9799
}
98100
std::vector<PokemonAutomation::PackedBinaryMatrix> matrices = compress_rgb32_to_binary_range(image, filters);
101+
// cout << matrices.size() << endl;
99102

100103
bool detected = false;
101104
bool stop_match = false;
@@ -116,10 +119,12 @@ bool match_template_by_waterfill(
116119
std::unique_ptr<Kernels::Waterfill::WaterfillSession> session = Kernels::Waterfill::make_WaterfillSession();
117120
Kernels::Waterfill::WaterfillObject object;
118121
const size_t min_area = area_thresholds.first;
122+
// cout << "min_area = " << min_area << endl;
119123
session->set_source(matrix);
120124
auto finder = session->make_iterator(min_area);
121125
const bool keep_object_matrix = false;
122126
while (finder->find_next(object, keep_object_matrix)){
127+
// cout << "object.area = " << object.area << endl;
123128
if (PreloadSettings::debug().IMAGE_TEMPLATE_MATCHING){
124129
std::cout << "------------" << std::endl;
125130
std::cout << "Object area: " << object.area << std::endl;

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
258258

259259

260260

261+
auto screenshot = feed.snapshot();
262+
263+
YCommIconDetector detector(true);
264+
cout << detector.process_frame(screenshot, current_time()) << endl;
265+
266+
261267
#if 0
262268
bool switch2 = true;
263269
ImageFloatBox key1_box;

SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_YCommDetector.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,12 @@ void YCommIconDetector::make_overlays(VideoOverlaySet& items) const{
9797
bool YCommIconDetector::process_frame(const ImageViewRGB32& frame, WallClock timestamp){
9898

9999
const std::vector<std::pair<uint32_t, uint32_t>> filters = {
100-
{combine_rgb(0, 0, 150), combine_rgb(100, 100, 255)}
100+
{combine_rgb(0, 0, 150), combine_rgb(100, 100, 255)},
101+
{combine_rgb(0, 0, 150), combine_rgb(127, 127, 255)},
102+
{combine_rgb(0, 0, 150), combine_rgb(191, 191, 255)},
101103
};
102104

103-
const double screen_rel_size = (frame.height() / 1080.0);
104-
const size_t min_size = size_t(screen_rel_size * screen_rel_size * 350.0);
105+
const size_t min_size = (size_t)(350. * frame.total_pixels() / (1920 * 1080.));
105106

106107
const bool detected = match_template_by_waterfill(
107108
extract_box_reference(frame, YCOMM_ICON_BOX),

0 commit comments

Comments
 (0)