From 43275815338e706146029e07a290973ff1c09024 Mon Sep 17 00:00:00 2001 From: jw098 Date: Fri, 1 Nov 2024 21:31:44 -0700 Subject: [PATCH] NoMinimapDetector --- SerialPrograms/CMakeLists.txt | 2 + SerialPrograms/SerialPrograms.pro | 2 + .../Overworld/PokemonSV_NoMinimapDetector.cpp | 44 +++++++++++++++ .../Overworld/PokemonSV_NoMinimapDetector.h | 53 +++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index da51665b9..6c1c2101c 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -1328,6 +1328,8 @@ file(GLOB MAIN_SOURCES Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoHpReader.h Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoKillDetector.cpp Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoKillDetector.h + Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.cpp + Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.cpp Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h Source/PokemonSV/Inference/Picnics/PokemonSV_PicnicDetector.cpp diff --git a/SerialPrograms/SerialPrograms.pro b/SerialPrograms/SerialPrograms.pro index 8f4cdea9a..b0e6b2e97 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -664,6 +664,7 @@ SOURCES += \ Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.cpp \ Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoHpReader.cpp \ Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoKillDetector.cpp \ + Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.cpp \ Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.cpp \ Source/PokemonSV/Inference/Picnics/PokemonSV_PicnicDetector.cpp \ Source/PokemonSV/Inference/Picnics/PokemonSV_SandwichHandDetector.cpp \ @@ -1758,6 +1759,7 @@ HEADERS += \ Source/PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h \ Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoHpReader.h \ Source/PokemonSV/Inference/Overworld/PokemonSV_LetsGoKillDetector.h \ + Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h \ Source/PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h \ Source/PokemonSV/Inference/Picnics/PokemonSV_PicnicDetector.h \ Source/PokemonSV/Inference/Picnics/PokemonSV_SandwichHandDetector.h \ diff --git a/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.cpp b/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.cpp new file mode 100644 index 000000000..40156a7ab --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.cpp @@ -0,0 +1,44 @@ +/* No Minimap Detector + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#include "Kernels/Waterfill/Kernels_Waterfill_Session.h" +#include "CommonFramework/Globals.h" +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "CommonFramework/ImageMatch/ImageDiff.h" +#include "CommonFramework/ImageMatch/ExactImageMatcher.h" +#include "CommonFramework/ImageTools/BinaryImage_FilterRgb32.h" +#include "CommonFramework/ImageTools/WaterfillUtilities.h" +#include "CommonFramework/ImageMatch/WaterfillTemplateMatcher.h" +#include "PokemonSV_NoMinimapDetector.h" + +//#include +//using std::cout; +//using std::endl; + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + + + +NoMinimapDetector::NoMinimapDetector(Logger& logger, Color color) + : m_color(color) + , m_ball(0.890, 0.800, 0.030, 0.060) + , m_overworld(color) +{} +void NoMinimapDetector::make_overlays(VideoOverlaySet& items) const{ + items.add(m_color, m_ball); +} +bool NoMinimapDetector::detect(const ImageViewRGB32& screen) const{ + return !m_overworld.detect(screen); +} + + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h b/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h new file mode 100644 index 000000000..055db0836 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h @@ -0,0 +1,53 @@ +/* No Minimap Detector + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PokemonSV_NoMinimapDetector_H +#define PokemonAutomation_PokemonSV_NoMinimapDetector_H + +#include "Common/Cpp/Color.h" +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "CommonFramework/InferenceInfra/VisualInferenceCallback.h" +#include "CommonFramework/Inference/VisualDetector.h" +#include "PokemonSV_OverworldDetector.h" + + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +// Detect that the minimap is not visible +class NoMinimapDetector : public StaticScreenDetector{ +public: + NoMinimapDetector(Logger& logger, Color color = COLOR_RED); + + virtual void make_overlays(VideoOverlaySet& items) const override; + virtual bool detect(const ImageViewRGB32& screen) const override; + + +protected: + const Color m_color; + const ImageFloatBox m_ball; + const OverworldDetector m_overworld; +}; + +class NoMinimapWatcher : public DetectorToFinder{ +public: + NoMinimapWatcher( + Logger& logger, + Color color = COLOR_RED, + std::chrono::milliseconds hold_duration = std::chrono::milliseconds(5000) + ) + : DetectorToFinder("GradientArrowWatcher", hold_duration, logger, color) + {} + +}; + + +} +} +} +#endif