Skip to content

Commit 2796830

Browse files
committed
Fix event raid filter.
1 parent 5432b0b commit 2796830

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

SerialPrograms/Source/CommonFramework/Inference/FrozenImageDetector.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ bool FrozenImageDetector::process_frame(const VideoSnapshot& frame){
4242
return false;
4343
}
4444

45-
double rmsd = ImageMatch::pixel_RMSD(m_previous, frame);
45+
double rmsd = ImageMatch::pixel_RMSD(
46+
extract_box_reference(m_previous, m_box),
47+
extract_box_reference(frame, m_box)
48+
);
4649
// cout << "rmsd = " << rmsd << endl;
4750
if (rmsd > m_rmsd_threshold){
4851
m_previous = frame;

SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ std::pair<double, double> OverworldDetector::locate_ball(const ImageViewRGB32& s
130130

131131

132132

133-
OverworldWatcher::OverworldWatcher(Logger& logger, Color color, bool detect_event)
133+
OverworldWatcher::OverworldWatcher(Logger& logger, Color color)
134134
: OverworldDetector(color)
135135
, VisualInferenceCallback("OverworldWatcher")
136136
, m_logger(logger)
@@ -139,7 +139,6 @@ OverworldWatcher::OverworldWatcher(Logger& logger, Color color, bool detect_even
139139
, m_north_hold_duration(std::chrono::milliseconds(1000))
140140
, m_last_ball(WallClock::min())
141141
, m_last_north(WallClock::min())
142-
, m_detect_event(detect_event)
143142
{
144143
m_direction_detector = DirectionDetector(COLOR_RED);
145144
}
@@ -176,7 +175,7 @@ bool OverworldWatcher::process_frame(const VideoSnapshot& frame){
176175
}
177176

178177
// Ball held for long enough. (5 seconds)
179-
if (!m_detect_event && (frame.timestamp - m_last_ball >= m_ball_hold_duration)){
178+
if (frame.timestamp - m_last_ball >= m_ball_hold_duration){
180179
return true;
181180
}
182181

@@ -197,8 +196,8 @@ bool OverworldWatcher::process_frame(const VideoSnapshot& frame){
197196
// Check if radar map stays still for 1 second.
198197

199198
// Mismatching image sizes.
200-
ImageViewRGB32 start = extract_box_reference(m_start_of_detection, m_detect_event ? m_ball : m_radar_inside);
201-
ImageViewRGB32 current = extract_box_reference(frame, m_detect_event ? m_ball : m_radar_inside);
199+
ImageViewRGB32 start = extract_box_reference(m_start_of_detection, m_radar_inside);
200+
ImageViewRGB32 current = extract_box_reference(frame, m_radar_inside);
202201
if (start.width() != current.width() || start.height() != current.height()){
203202
m_start_of_detection = frame;
204203
return false;

SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class OverworldDetector : public StaticScreenDetector{
4040

4141
class OverworldWatcher : public OverworldDetector, public VisualInferenceCallback{
4242
public:
43-
OverworldWatcher(Logger& logger, Color color = COLOR_RED, bool detect_event = false);
43+
OverworldWatcher(Logger& logger, Color color = COLOR_RED);
4444

4545
virtual void make_overlays(VideoOverlaySet& items) const override;
4646
virtual bool process_frame(const VideoSnapshot& frame) override;
@@ -54,7 +54,6 @@ class OverworldWatcher : public OverworldDetector, public VisualInferenceCallbac
5454
WallClock m_last_ball;
5555
WallClock m_last_north;
5656
VideoSnapshot m_start_of_detection;
57-
bool m_detect_event;
5857
DirectionDetector m_direction_detector;
5958
};
6059

SerialPrograms/Source/PokemonSV/Programs/TeraRaids/PokemonSV_TeraRoutines.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
1414
#include "CommonFramework/Tools/ProgramEnvironment.h"
1515
#include "CommonFramework/Tools/ErrorDumper.h"
16+
#include "CommonFramework/Inference/FrozenImageDetector.h"
1617
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
1718
#include "Pokemon/Pokemon_Strings.h"
1819
#include "Pokemon/Pokemon_Notification.h"
@@ -30,6 +31,10 @@
3031
#include "PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h"
3132
#include "PokemonSV_TeraRoutines.h"
3233

34+
//#include <iostream>
35+
//using std::cout;
36+
//using std::endl;
37+
3338
namespace PokemonAutomation{
3439
namespace NintendoSwitch{
3540
namespace PokemonSV{
@@ -709,8 +714,17 @@ void run_from_tera_battle(const ProgramInfo& info, ConsoleHandle& console, BotBa
709714
}
710715

711716

717+
718+
712719
bool is_sparkling_raid(ConsoleHandle& console, BotBaseContext& context){
713-
OverworldWatcher static_map(console, COLOR_CYAN, true);
720+
// cout << "is_sparkling_raid()" << endl;
721+
722+
FrozenImageDetector static_map(
723+
COLOR_RED,
724+
{0.890, 0.800, 0.030, 0.060},
725+
std::chrono::seconds(1), 20
726+
);
727+
714728
context.wait_for_all_requests();
715729

716730
int ret = wait_until(

0 commit comments

Comments
 (0)