Skip to content

Commit d2b005e

Browse files
committed
Relax AutoDA HP detection threshold to reduce errors.
1 parent c3bb200 commit d2b005e

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
#include "PokemonLA/Inference/Objects/PokemonLA_MMOQuestionMarkDetector.h"
128128
//#include "PokemonSwSh/Inference/Battles/PokemonSwSh_BattleMenuDetector.h"
129129
#include "PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_BattleMenu.h"
130+
#include "PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_PokemonSwapMenu.h"
130131

131132

132133
#include <QPixmap>
@@ -279,11 +280,14 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
279280
VideoOverlaySet overlays(overlay);
280281

281282

282-
PokemonSwSh::MaxLairInternal::BattleMenuReader reader(console, Language::Korean);
283+
PokemonSwSh::MaxLairInternal::PokemonSwapMenuReader reader(console, overlay, Language::English);
284+
285+
ImageRGB32 image("20241221-123730238930.png");
283286

284-
ImageRGB32 image("20241220-161934162025.png");
287+
double hp[4];
288+
reader.read_hp(image, hp);
285289

286-
reader.read_opponent_in_summary(logger, image);
290+
// reader.read_opponent_in_summary(logger, image);
287291

288292
// PokemonSwSh::find_selection_arrows(image, 10);
289293

SerialPrograms/Source/Pokemon/Inference/Pokemon_ReadHpBar.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include "CommonFramework/ImageTools/ImageStats.h"
1010
#include "Pokemon_ReadHpBar.h"
1111

12+
//#include <iostream>
13+
//using std::cout;
14+
//using std::endl;
15+
1216
namespace PokemonAutomation{
1317
namespace Pokemon{
1418

@@ -18,6 +22,11 @@ double read_hp_bar_internal(const ImageViewRGB32& image){
1822
size_t height = image.height();
1923
size_t area = width * height;
2024

25+
// REMOVE
26+
static int i = 0;
27+
image.save("test-" + std::to_string(++i) + ".png");
28+
// cout << "start: " << i << endl;
29+
2130
ImageStats stats;
2231
double bar = 0.5;
2332
for (size_t c = 0;; c++){
@@ -26,7 +35,8 @@ double read_hp_bar_internal(const ImageViewRGB32& image){
2635
max_color = std::max(max_color, stats.average.r);
2736
max_color = std::max(max_color, stats.average.g);
2837
max_color = std::max(max_color, stats.average.b);
29-
if (max_color > 128 && stats.stddev.sum() < 50){
38+
// cout << "max_color: " << max_color << ", stddev: " << stats.stddev.sum() << endl;
39+
if (max_color > 128 && stats.stddev.sum() < 70){
3040
break;
3141
}
3242
bar *= 0.5;
@@ -39,6 +49,7 @@ double read_hp_bar_internal(const ImageViewRGB32& image){
3949
: -1;
4050
}
4151
}
52+
// cout << "end: " << i << endl;
4253

4354
Color color = stats.average.round();
4455
int bar_R = color.red();

0 commit comments

Comments
 (0)