Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMinimapDetector #500

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <iostream>
//using std::cout;
//using std::endl;

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{



NoMinimapDetector::NoMinimapDetector(Logger& logger, Color color)
: m_color(color)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need m_color and m_ball separately just for the overlay? Can't we make m_overworld do the overlay directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted NoMinimapDetector's overlay to look slightly different than the Overworld detector's overlay. Overworld detector has 3 boxes in its overlay, while NoMinimapDetector's overlay is only the smallest inner box. This way, users can tell when we're looking or the Overworld, and when we're looking for no overworld.

I don't feel strongly about this though. If you prefer to use the Overworld's overlay, I can change it.

, 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);
}




}
}
}
Original file line number Diff line number Diff line change
@@ -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<NoMinimapDetector>{
public:
NoMinimapWatcher(
Logger& logger,
Color color = COLOR_RED,
std::chrono::milliseconds hold_duration = std::chrono::milliseconds(5000)
)
: DetectorToFinder("GradientArrowWatcher", hold_duration, logger, color)
{}

};


}
}
}
#endif
Loading