Skip to content

Commit 9811e3d

Browse files
authored
NoMinimapDetector (#500)
1 parent 5c075a2 commit 9811e3d

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,8 @@ file(GLOB MAIN_SOURCES
13301330
Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoHpReader.h
13311331
Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoKillDetector.cpp
13321332
Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoKillDetector.h
1333+
Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.cpp
1334+
Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h
13331335
Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.cpp
13341336
Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h
13351337
Source/PokemonSV/Inference/Overworld/PokemonSV_StationaryOverworldWatcher.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ SOURCES += \
665665
Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp \
666666
Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoHpReader.cpp \
667667
Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoKillDetector.cpp \
668+
Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.cpp \
668669
Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.cpp \
669670
Source/PokemonSV/Inference/Overworld/PokemonSV_StationaryOverworldWatcher.cpp \
670671
Source/PokemonSV/Inference/Picnics/PokemonSV_PicnicDetector.cpp \
@@ -1763,6 +1764,7 @@ HEADERS += \
17631764
Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h \
17641765
Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoHpReader.h \
17651766
Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoKillDetector.h \
1767+
Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h \
17661768
Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h \
17671769
Source/PokemonSV/Inference/Overworld/PokemonSV_StationaryOverworldWatcher.h \
17681770
Source/PokemonSV/Inference/Picnics/PokemonSV_PicnicDetector.h \
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* No Minimap Detector
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "Kernels/Waterfill/Kernels_Waterfill_Session.h"
8+
#include "CommonFramework/Globals.h"
9+
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
10+
#include "CommonFramework/ImageMatch/ImageDiff.h"
11+
#include "CommonFramework/ImageMatch/ExactImageMatcher.h"
12+
#include "CommonFramework/ImageTools/BinaryImage_FilterRgb32.h"
13+
#include "CommonFramework/ImageTools/WaterfillUtilities.h"
14+
#include "CommonFramework/ImageMatch/WaterfillTemplateMatcher.h"
15+
#include "PokemonSV_NoMinimapDetector.h"
16+
17+
//#include <iostream>
18+
//using std::cout;
19+
//using std::endl;
20+
21+
namespace PokemonAutomation{
22+
namespace NintendoSwitch{
23+
namespace PokemonSV{
24+
25+
26+
27+
NoMinimapDetector::NoMinimapDetector(Logger& logger, Color color)
28+
: m_color(color)
29+
, m_ball(0.890, 0.800, 0.030, 0.060)
30+
, m_overworld(color)
31+
{}
32+
void NoMinimapDetector::make_overlays(VideoOverlaySet& items) const{
33+
items.add(m_color, m_ball);
34+
}
35+
bool NoMinimapDetector::detect(const ImageViewRGB32& screen) const{
36+
return !m_overworld.detect(screen);
37+
}
38+
39+
40+
41+
42+
}
43+
}
44+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* No Minimap Detector
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonSV_NoMinimapDetector_H
8+
#define PokemonAutomation_PokemonSV_NoMinimapDetector_H
9+
10+
#include "Common/Cpp/Color.h"
11+
#include "CommonFramework/ImageTools/ImageBoxes.h"
12+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
13+
#include "CommonFramework/InferenceInfra/VisualInferenceCallback.h"
14+
#include "CommonFramework/Inference/VisualDetector.h"
15+
#include "PokemonSV_OverworldDetector.h"
16+
17+
18+
namespace PokemonAutomation{
19+
namespace NintendoSwitch{
20+
namespace PokemonSV{
21+
22+
// Detect that the minimap is not visible
23+
class NoMinimapDetector : public StaticScreenDetector{
24+
public:
25+
NoMinimapDetector(Logger& logger, Color color = COLOR_RED);
26+
27+
virtual void make_overlays(VideoOverlaySet& items) const override;
28+
virtual bool detect(const ImageViewRGB32& screen) const override;
29+
30+
31+
protected:
32+
const Color m_color;
33+
const ImageFloatBox m_ball;
34+
const OverworldDetector m_overworld;
35+
};
36+
37+
class NoMinimapWatcher : public DetectorToFinder<NoMinimapDetector>{
38+
public:
39+
NoMinimapWatcher(
40+
Logger& logger,
41+
Color color = COLOR_RED,
42+
std::chrono::milliseconds hold_duration = std::chrono::milliseconds(5000)
43+
)
44+
: DetectorToFinder("GradientArrowWatcher", hold_duration, logger, color)
45+
{}
46+
47+
};
48+
49+
50+
}
51+
}
52+
}
53+
#endif

0 commit comments

Comments
 (0)