Skip to content

Commit 7c05405

Browse files
kichithewolfGin890
authored andcommitted
hyperspace reward name reader
1 parent a0147bf commit 7c05405

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* Hyperspace Reward Name Reader
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "CommonTools/OCR/OCR_RawOCR.h"
8+
#include "PokemonLZA_HyperspaceRewardNameReader.h"
9+
10+
namespace PokemonAutomation{
11+
namespace NintendoSwitch{
12+
namespace PokemonLZA{
13+
14+
HyperspaceRewardNameReader& HyperspaceRewardNameReader::instance(){
15+
static HyperspaceRewardNameReader reader;
16+
return reader;
17+
}
18+
19+
20+
HyperspaceRewardNameReader::HyperspaceRewardNameReader()
21+
: SmallDictionaryMatcher("PokemonSV/AAT/TournamentPrizeNameOCR.json") //TODO: Get actual reward list
22+
{}
23+
24+
OCR::StringMatchResult HyperspaceRewardNameReader::read_substring(
25+
Logger& logger,
26+
Language language,
27+
const ImageViewRGB32& image,
28+
const std::vector<OCR::TextColorRange>& text_color_ranges,
29+
double min_text_ratio, double max_text_ratio
30+
) const{
31+
return match_substring_from_image_multifiltered(
32+
&logger, language, image, text_color_ranges,
33+
MAX_LOG10P, MAX_LOG10P_SPREAD, min_text_ratio, max_text_ratio
34+
);
35+
}
36+
37+
}
38+
}
39+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* Hyperspace Reward Name Reader
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonLZA_HyperspaceRewardNameReader_H
8+
#define PokemonAutomation_PokemonLZA_HyperspaceRewardNameReader_H
9+
10+
#include "CommonTools/OCR/OCR_SmallDictionaryMatcher.h"
11+
12+
namespace PokemonAutomation{
13+
namespace NintendoSwitch{
14+
namespace PokemonLZA{
15+
16+
class HyperspaceRewardNameReader : public OCR::SmallDictionaryMatcher{
17+
public:
18+
static constexpr double MAX_LOG10P = -1.40;
19+
static constexpr double MAX_LOG10P_SPREAD = 0.50;
20+
21+
public:
22+
HyperspaceRewardNameReader();
23+
24+
static HyperspaceRewardNameReader& instance();
25+
26+
OCR::StringMatchResult read_substring(
27+
Logger& logger,
28+
Language language,
29+
const ImageViewRGB32& image,
30+
const std::vector<OCR::TextColorRange>& text_color_ranges,
31+
double min_text_ratio = 0.01, double max_text_ratio = 0.50
32+
) const;
33+
34+
};
35+
}
36+
}
37+
}
38+
#endif

SerialPrograms/SourceFiles.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,8 @@ file(GLOB LIBRARY_SOURCES
16071607
Source/PokemonLZA/Inference/PokemonLZA_DayNightChangeDetector.h
16081608
Source/PokemonLZA/Inference/PokemonLZA_DialogDetector.cpp
16091609
Source/PokemonLZA/Inference/PokemonLZA_DialogDetector.h
1610+
Source/PokemonLZA/Inference/PokemonLZA_HyperspaceRewardNameReader.cpp
1611+
Source/PokemonLZA/Inference/PokemonLZA_HyperspaceRewardNameReader.h
16101612
Source/PokemonLZA/Inference/PokemonLZA_MainMenuDetector.cpp
16111613
Source/PokemonLZA/Inference/PokemonLZA_MainMenuDetector.h
16121614
Source/PokemonLZA/Inference/PokemonLZA_OverworldPartySelectionDetector.cpp
@@ -1631,6 +1633,8 @@ file(GLOB LIBRARY_SOURCES
16311633
Source/PokemonLZA/PokemonLZA_Settings.h
16321634
Source/PokemonLZA/Programs/Farming/PokemonLZA_FriendshipFarmer.cpp
16331635
Source/PokemonLZA/Programs/Farming/PokemonLZA_FriendshipFarmer.h
1636+
Source/PokemonLZA/Programs/Farming/PokemonLZA_HyperspaceRewardReset.cpp
1637+
Source/PokemonLZA/Programs/Farming/PokemonLZA_HyperspaceRewardReset.h
16341638
Source/PokemonLZA/Programs/Farming/PokemonLZA_InPlaceCatcher.cpp
16351639
Source/PokemonLZA/Programs/Farming/PokemonLZA_InPlaceCatcher.h
16361640
Source/PokemonLZA/Programs/Farming/PokemonLZA_JacintheInfiniteFarmer.cpp

0 commit comments

Comments
 (0)