Skip to content
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/Source/PanelLists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "PokemonSwSh/PokemonSwSh_Panels.h"
#include "PokemonHome/PokemonHome_Panels.h"
#include "PokemonBDSP/PokemonBDSP_Panels.h"
#include "PokemonFRLG/PokemonFRLG_Panels.h"
#include "PokemonLA/PokemonLA_Panels.h"
#include "PokemonLGPE/PokemonLGPE_Panels.h"
#include "PokemonRSE/PokemonRSE_Panels.h"
Expand Down Expand Up @@ -56,6 +57,7 @@ ProgramSelect::ProgramSelect(QWidget& parent, PanelHolder& holder)
add(std::make_unique<NintendoSwitch::PokemonLZA::PanelListFactory>());
if (PreloadSettings::instance().DEVELOPER_MODE){
add(std::make_unique<NintendoSwitch::PokemonRSE::PanelListFactory>());
add(std::make_unique<NintendoSwitch::PokemonFRLG::PanelListFactory>());
}

add(std::make_unique<NintendoSwitch::ZeldaTotK::PanelListFactory>());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/* Dialog Detector
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "CommonTools/Images/SolidColorTest.h"
#include "CommonTools/Images/ImageFilter.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonFramework/ImageTypes/ImageRGB32.h"
#include "CommonFramework/ImageTools/ImageStats.h"
#include "CommonFramework/ImageTypes/ImageViewRGB32.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonTools/Images/SolidColorTest.h"
#include "CommonTools/Images/WaterfillUtilities.h"
#include "CommonTools/ImageMatch/WaterfillTemplateMatcher.h"
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
#include "PokemonFRLG_DialogDetector.h"

//#include <iostream>
//using std::cout;
//using std::endl;

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{

WhiteDialogDetector::WhiteDialogDetector(Color color)
: m_right_box(0.812, 0.726, 0.013, 0.169)
, m_top_box(0.175, 0.715, 0.649, 0.005)
, m_bottom_box(0.177, 0.896, 0.645, 0.008)
{}
void WhiteDialogDetector::make_overlays(VideoOverlaySet& items) const{
items.add(COLOR_RED, m_right_box);
items.add(COLOR_RED, m_top_box);
items.add(COLOR_RED, m_bottom_box);
}
bool WhiteDialogDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box);
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
if (is_solid(right_image, { 0.25, 0.38, 0.369 })
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
){
return true;
}
return false;
}

AdvanceWhiteDialogDetector::AdvanceWhiteDialogDetector(Color color)
: m_dialog_box(0.170, 0.726, 0.655, 0.172)
, m_right_box(0.812, 0.726, 0.013, 0.169)
, m_top_box(0.175, 0.715, 0.649, 0.005)
, m_bottom_box(0.177, 0.896, 0.645, 0.008)
{}
void AdvanceWhiteDialogDetector::make_overlays(VideoOverlaySet& items) const{
items.add(COLOR_RED, m_dialog_box);
items.add(COLOR_RED, m_right_box);
items.add(COLOR_RED, m_top_box);
items.add(COLOR_RED, m_bottom_box);
}
bool AdvanceWhiteDialogDetector::detect(const ImageViewRGB32& screen){
const bool replace_color_within_range = false;

//Filter out background
ImageRGB32 filtered_region = filter_rgb32_range(
extract_box_reference(screen, m_dialog_box),
combine_rgb(185, 0, 1), combine_rgb(255, 32, 33), Color(0), replace_color_within_range
);
ImageStats stats = image_stats(filtered_region);

/*
filtered_region.save("./filtered_only.png");
cout << stats.average.r << endl;
cout << stats.average.g << endl;
cout << stats.average.b << endl;
*/

ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box);
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);

if (is_solid(right_image, { 0.25, 0.38, 0.369 })
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
&& (stats.average.r > stats.average.b + 200)
&& (stats.average.r > stats.average.g + 200)
)
{
return true;
}
return false;
}

SelectionDialogDetector::SelectionDialogDetector(Color color)
: m_right_box(0.812, 0.726, 0.013, 0.169)
, m_top_box(0.175, 0.715, 0.649, 0.005)
, m_bottom_box(0.177, 0.896, 0.645, 0.008)
, m_selection_box(0.783, 0.457, 0.017, 0.177)
{}
void SelectionDialogDetector::make_overlays(VideoOverlaySet& items) const{
items.add(COLOR_RED, m_right_box);
items.add(COLOR_RED, m_top_box);
items.add(COLOR_RED, m_bottom_box);
items.add(COLOR_RED, m_selection_box);
}
bool SelectionDialogDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box);
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
ImageViewRGB32 selection_image = extract_box_reference(screen, m_selection_box);
if (is_solid(right_image, { 0.25, 0.38, 0.369 })
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
&& is_solid(selection_image, { 0.25, 0.38, 0.369 })
){
return true;
}
return false;
}


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* Dialog Detector
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_PokemonFRLG_DialogDetector_H
#define PokemonAutomation_PokemonFRLG_DialogDetector_H

#include <chrono>
#include <atomic>
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "Common/Cpp/Color.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonTools/VisualDetector.h"
#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h"

namespace PokemonAutomation{
class CancellableScope;
class VideoFeed;
namespace NintendoSwitch{
namespace PokemonFRLG{

// When given a choice popup, there is no advance arrow.
// FRLG doesn't have an advance arrow on the final line of dialog when speaking to an npc!

//Standard - npc dialog, interacting with items, etc.
//tutorial - white box with grey mat like a picture frame

// Common dialog box for npcs, etc.
// This one detects the final line spoken, so no red arrow
// This also detects all the other white dialogs, so use sparingly
class WhiteDialogDetector : public StaticScreenDetector{
public:
WhiteDialogDetector(Color color);

virtual void make_overlays(VideoOverlaySet& items) const override;
virtual bool detect(const ImageViewRGB32& screen) override;

private:
ImageFloatBox m_right_box;
ImageFloatBox m_top_box;
ImageFloatBox m_bottom_box;
};
class WhiteDialogWatcher : public DetectorToFinder<WhiteDialogDetector>{
public:
WhiteDialogWatcher(Color color)
: DetectorToFinder("WhiteDialogWatcher", std::chrono::milliseconds(250), color)
{}
};

// Same as WhiteDialogDetector, but filter for the red arrow
// Detect the red advancement arrow by filtering for DARK red.
// There is red/pink color text for female npcs in non-japan versions
// might be an issue if using it for things other than shiny-hunt resetting
// all gifts are black/blue dialogs?
class AdvanceWhiteDialogDetector : public StaticScreenDetector{
public:
AdvanceWhiteDialogDetector(Color color);

virtual void make_overlays(VideoOverlaySet& items) const override;
virtual bool detect(const ImageViewRGB32& screen) override;

private:
ImageFloatBox m_dialog_box;
ImageFloatBox m_right_box;
ImageFloatBox m_top_box;
ImageFloatBox m_bottom_box;
};
class AdvanceWhiteDialogWatcher : public DetectorToFinder<AdvanceWhiteDialogDetector>{
public:
AdvanceWhiteDialogWatcher(Color color)
: DetectorToFinder("AdvanceWhiteDialogWatcher", std::chrono::milliseconds(250), color)
{}
};

// Same as WhiteDialogDetector, but also looks for the white of the Yes/No box
class SelectionDialogDetector : public StaticScreenDetector{
public:
SelectionDialogDetector(Color color);

virtual void make_overlays(VideoOverlaySet& items) const override;
virtual bool detect(const ImageViewRGB32& screen) override;

private:
ImageFloatBox m_right_box;
ImageFloatBox m_top_box;
ImageFloatBox m_bottom_box;
ImageFloatBox m_selection_box;
};
class SelectionDialogWatcher : public DetectorToFinder<SelectionDialogDetector>{
public:
SelectionDialogWatcher(Color color)
: DetectorToFinder("SelectionDialogWatcher", std::chrono::milliseconds(250), color)
{}
};




}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* Start Menu Detector
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "CommonTools/Images/SolidColorTest.h"
#include "CommonTools/Images/ImageFilter.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonFramework/ImageTypes/ImageRGB32.h"
#include "CommonFramework/ImageTools/ImageStats.h"
#include "CommonFramework/ImageTypes/ImageViewRGB32.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonTools/Images/SolidColorTest.h"
#include "CommonTools/Images/WaterfillUtilities.h"
#include "CommonTools/ImageMatch/WaterfillTemplateMatcher.h"
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
#include "PokemonFRLG_StartMenuDetector.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{

StartMenuDetector::StartMenuDetector(Color color)
: m_right_box(0.864, 0.750, 0.006, 0.173)
, m_top_box(0.128, 0.744, 0.743, 0.006)
, m_bottom_box(0.128, 0.917, 0.736, 0.006)
{}
void StartMenuDetector::make_overlays(VideoOverlaySet& items) const{
items.add(COLOR_RED, m_right_box);
items.add(COLOR_RED, m_top_box);
items.add(COLOR_RED, m_bottom_box);
}
bool StartMenuDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box);
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
if (is_solid(right_image, { 0.00, 0.38, 0.62 })
&& is_solid(top_image, { 0.00, 0.38, 0.62 })
&& is_solid(bottom_image, { 0.00, 0.38, 0.62 })
){
return true;
}
return false;
}


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* Start Menu Detector
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_PokemonFRLG_StartMenuDetector_H
#define PokemonAutomation_PokemonFRLG_StartMenuDetector_H

#include <chrono>
#include <atomic>
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "Common/Cpp/Color.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonTools/VisualDetector.h"
#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h"

namespace PokemonAutomation{
class CancellableScope;
class VideoFeed;
namespace NintendoSwitch{
namespace PokemonFRLG{

// Detect Start menu by looking for the blue info panel
class StartMenuDetector : public StaticScreenDetector{
public:
StartMenuDetector(Color color);

virtual void make_overlays(VideoOverlaySet& items) const override;
virtual bool detect(const ImageViewRGB32& screen) override;

private:
ImageFloatBox m_right_box;
ImageFloatBox m_top_box;
ImageFloatBox m_bottom_box;
};
class StartMenuWatcher : public DetectorToFinder<StartMenuDetector>{
public:
StartMenuWatcher(Color color)
: DetectorToFinder("StartMenuWatcher", std::chrono::milliseconds(250), color)
{}
};


}
}
}

#endif
Loading