Skip to content

Commit

Permalink
Fix summary detector for certain shades of green.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticial committed Oct 3, 2023
1 parent 4b9ec0e commit 5484515
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ void TestProgramComputer::program(ProgramEnvironment& env, CancellableScope& sco
// using namespace NintendoSwitch::PokemonSwSh::MaxLairInternal;




ImageRGB32 image("screenshot-20231003-202430049819.png");
PokemonSummaryDetector detector;
cout << detector.detect(image) << endl;





#if 0
uint8_t low_iv;
uint8_t high_iv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,19 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
VideoOverlaySet overlays(overlay);


// ImageRGB32 image("screenshot-20231003-202430049819.png");
auto snapshot = console.video().snapshot();

PokemonSummaryDetector detector;
cout << detector.detect(snapshot) << endl;


#if 0
SummaryStatsReader reader;
reader.make_overlays(overlays);

auto snapshot = console.video().snapshot();

#if 1
NatureAdjustments nature = reader.read_nature(logger, snapshot);
cout << "attack = " << (int)nature.attack << endl;
cout << "defense = " << (int)nature.defense << endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "CommonFramework/ImageTools/SolidColorTest.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "PokemonSV_PokemonSummaryReader.h"
#include "PokemonSV_BagDetector.h"

//#include <iostream>
Expand Down Expand Up @@ -49,10 +50,7 @@ bool BagDetector::detect(const ImageViewRGB32& screen) const{
return false;
}
#else
if (!is_solid(bottom, {0.648549, 0.286158, 0.0652928}, 0.15, 20) && // Scarlet
!is_solid(bottom, {0.367816, 0.0746615, 0.557523}, 0.15, 20) && // Violet
!is_solid(bottom, {0.137949, 0.708023, 0.154028}, 0.15, 20) // DLC Green
){
if (!is_summary_color(bottom)){
return false;
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "PokemonSV_PokemonSummaryReader.h"

// REMOVE
#include <iostream>
using std::cout;
using std::endl;
Expand All @@ -18,6 +19,14 @@ namespace PokemonSV{



bool is_summary_color(const ImageStats& stats){
return is_solid(stats, {0.648549, 0.2861580, 0.0652928}, 0.15, 20) // Scarlet
|| is_solid(stats, {0.367816, 0.0746615, 0.5575230}, 0.15, 20) // Violet
|| is_solid(stats, {0.196536, 0.5933000, 0.2101630}, 0.18, 20); // DLC Green
}



PokemonSummaryDetector::PokemonSummaryDetector(Color color)
: m_color(color)
, m_top_blue_left(0.30, 0.09, 0.10, 0.05)
Expand All @@ -35,26 +44,25 @@ bool PokemonSummaryDetector::detect(const ImageViewRGB32& screen) const{
ImageStats top_blue_left = image_stats(extract_box_reference(screen, m_top_blue_left));
// cout << top_blue_left.average << top_blue_left.stddev << endl;
if (!is_solid(top_blue_left, {0.0745162, 0.311321, 0.614163}, 0.30, 10)){
// cout << "bad: blue left" << endl;
return false;
}

ImageStats top_blue_right = image_stats(extract_box_reference(screen, m_top_blue_right));
// cout << top_blue_right.average << top_blue_right.stddev << endl;
if (!is_solid(top_blue_right, {0.0745162, 0.311321, 0.614163}, 0.30, 10)){
// cout << "bad: blue right" << endl;
return false;
}

ImageStats bottom = image_stats(extract_box_reference(screen, m_bottom));
// cout << bottom.average << bottom.stddev << endl;
cout << bottom.average << bottom.stddev << endl;
#if 0
if (bottom.stddev.sum() > 20){
return false;
}
#else
if (!is_solid(bottom, {0.648549, 0.286158, 0.0652928}, 0.15, 20) && // Scarlet
!is_solid(bottom, {0.367816, 0.0746615, 0.557523}, 0.15, 20) && // Violet
!is_solid(bottom, {0.137949, 0.708023, 0.154028}, 0.15, 20) // DLC Green
){
if (!is_summary_color(bottom)){
return false;
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
#include "CommonFramework/Inference/VisualDetector.h"

namespace PokemonAutomation{
struct ImageStats;
namespace NintendoSwitch{
namespace PokemonSV{


bool is_summary_color(const ImageStats& stats);



class PokemonSummaryDetector : public StaticScreenDetector{
public:
Expand Down

0 comments on commit 5484515

Please sign in to comment.