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
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,29 @@ bool BattleLearnDialogDetector::detect(const ImageViewRGB32& screen){
return false;
}

BattleOutOfPpDetector::BattleOutOfPpDetector(Color color)
: m_box(0.692901, 0.758376, 0.275753, 0.085431)
, m_area_ratio_threshold(0.01)
{}
void BattleOutOfPpDetector::make_overlays(VideoOverlaySet& items) const{
const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX;
items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_box));
}
bool BattleOutOfPpDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX);
const auto region = extract_box_reference(game_screen, m_box);

// Retain only red pixels from region ( ~ RGB(225, 74, 27) )
const bool replace_color_within_range = false;
const ImageRGB32 red_region = filter_rgb32_range(
region,
combine_rgb(150, 0, 0), combine_rgb(255, 150, 150), Color(0), replace_color_within_range
);
const size_t num_red_pixels = image_stats(red_region).count;
const double threshold = region.width() * region.height() * m_area_ratio_threshold;

return num_red_pixels > threshold;
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,25 @@ class BattleLearnDialogDetector : public StaticScreenDetector{
class BattleLearnDialogWatcher : public DetectorToFinder<BattleLearnDialogDetector>{
public:
BattleLearnDialogWatcher(Color color)
: DetectorToFinder("BattleLearnDialogDetector", std::chrono::milliseconds(250), color)
: DetectorToFinder("BattleLearnDialogWatcher", std::chrono::milliseconds(250), color)
{}
};

class BattleOutOfPpDetector : public StaticScreenDetector{
public:
BattleOutOfPpDetector(Color color);

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

private:
ImageFloatBox m_box;
double m_area_ratio_threshold;
};
class BattleOutOfPpWatcher : public DetectorToFinder<BattleOutOfPpDetector>{
public:
BattleOutOfPpWatcher(Color color)
: DetectorToFinder("BattleOutOfPpWatcher", std::chrono::milliseconds(250), color)
{}
};

Expand Down