Skip to content
Closed
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
@@ -0,0 +1,53 @@
/* Map Fly Point Label Reader
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "CommonFramework/ImageTypes/ImageRGB32.h"
#include "CommonTools/Images/ImageFilter.h"
#include "CommonTools/OCR/OCR_Routines.h"
#include "PokemonSV_MapFlyPointLabelReader.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{


// The label is a white box centered above the cursor, which sits at the
// middle of the screen. On a lab screenshot (2026-10-22, the zoom level the
// map opens with) the box for 中心廣場 spans x 0.426-0.574, y 0.341-0.408.
// The read area keeps inside it vertically, and is wider so that longer
// names fit.
MapFlyPointLabelReader::MapFlyPointLabelReader()
: m_box(0.250, 0.348, 0.500, 0.054)
{}

void MapFlyPointLabelReader::make_overlays(VideoOverlaySet& items) const{
items.add(COLOR_BLUE, m_box);
}

std::string MapFlyPointLabelReader::read(Logger& logger, Language language, const ImageViewRGB32& screen) const{
// Keep the label's dark text and blank everything else, including most
// of the map around the label.
ImageRGB32 filtered = to_blackwhite_rgb32_range(
extract_box_reference(screen, m_box),
true,
0xff000000, 0xff707070
);

std::string ret;
for (char ch : OCR::ocr_read(language, filtered)){
if ((unsigned char)ch < 32){
continue;
}
ret += ch;
}
logger.log("Map fly point label: \"" + ret + "\"");
return ret;
}


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Map Fly Point Label Reader
*
* From: https://github.com/PokemonAutomation/
*
* Read the name label the map shows above the cursor when the cursor is on
* a fly point.
*
*/

#ifndef PokemonAutomation_PokemonSV_MapFlyPointLabelReader_H
#define PokemonAutomation_PokemonSV_MapFlyPointLabelReader_H

#include <string>
#include "Common/Cpp/Logging/AbstractLogger.h"
#include "CommonFramework/Language.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonFramework/ImageTypes/ImageViewRGB32.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{


class MapFlyPointLabelReader{
public:
MapFlyPointLabelReader();

void make_overlays(VideoOverlaySet& items) const;

// OCR the label's dark text. Returns the raw OCR text, which is empty
// (or noise) when there is no label.
std::string read(Logger& logger, Language language, const ImageViewRGB32& screen) const;

private:
ImageFloatBox m_box;
};


}
}
}
#endif
Loading
Loading