-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ruby/sapphire starter reset #525
Open
kichithewolf
wants to merge
12
commits into
PokemonAutomation:main
Choose a base branch
from
kichithewolf:gba-rg35xxsp-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
60381a0
kichi's dev token
kichithewolf 96efeb1
pokemon emerald game dropdown/panels
kichithewolf eb36c8d
rename to rse, starter reset test
kichithewolf 347a94f
configurable button timings, test sound listener
kichithewolf b5c2e2d
Merge branch 'PokemonAutomation:main' into gba-rg35xxsp-test
kichithewolf c62ae24
audio only feedback type, rename program
kichithewolf 0b2b030
shiny reset, battle menu+shiny number detect
kichithewolf 6643e9d
dev mode locks
kichithewolf 59beefa
more dialog infra, improve audio starter reset
kichithewolf 4bf5931
working audio starter detection
kichithewolf b67a8c8
gba black borders
kichithewolf db42cdb
update notifications, unblock settings
kichithewolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
SerialPrograms/Source/CommonFramework/Inference/BlackBorderGBADetector.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* Black Border Detector | ||
* | ||
* From: https://github.com/PokemonAutomation/Arduino-Source | ||
* | ||
*/ | ||
|
||
#include "CommonFramework/ImageTools/ImageStats.h" | ||
#include "CommonFramework/ImageTools/SolidColorTest.h" | ||
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" | ||
#include "BlackBorderGBADetector.h" | ||
|
||
#include <iostream> | ||
using std::cout; | ||
using std::endl; | ||
|
||
namespace PokemonAutomation{ | ||
|
||
|
||
BlackBorderGBADetector::BlackBorderGBADetector() | ||
: m_top(0.126, 0.055, 0.748, 0.006) | ||
, m_bottom(0.124, 0.940, 0.751, 0.004) | ||
, m_left(0.126, 0.055, 0.002, 0.888) | ||
, m_right(0.871, 0.055, 0.003, 0.888) | ||
// , m_body(0.100, 0.100, 0.800, 0.800) | ||
{} | ||
|
||
void BlackBorderGBADetector::make_overlays(VideoOverlaySet& items) const{ | ||
items.add(COLOR_RED, m_top); | ||
items.add(COLOR_RED, m_bottom); | ||
items.add(COLOR_RED, m_left); | ||
items.add(COLOR_RED, m_right); | ||
// items.add(COLOR_RED, m_body); | ||
} | ||
bool BlackBorderGBADetector::detect(const ImageViewRGB32& screen) const{ | ||
const double MAX_SUM = 50; | ||
const double MAX_STDDEV = 20; | ||
|
||
ImageStats top = image_stats(extract_box_reference(screen, m_top)); | ||
// cout << "top = " << top.average << top.stddev << endl; | ||
// extract_box(screen, m_top).save("top.png"); | ||
if (!is_black(top, MAX_SUM, MAX_STDDEV)){ | ||
return false; | ||
} | ||
ImageStats bottom = image_stats(extract_box_reference(screen, m_bottom)); | ||
// cout << "bottom = " << bottom.average << bottom.stddev << endl; | ||
if (!is_black(bottom, MAX_SUM, MAX_STDDEV)){ | ||
return false; | ||
} | ||
ImageStats left = image_stats(extract_box_reference(screen, m_left)); | ||
// cout << "left = " << left.average << left.stddev << endl; | ||
if (!is_black(left, MAX_SUM, MAX_STDDEV)){ | ||
return false; | ||
} | ||
ImageStats right = image_stats(extract_box_reference(screen, m_right)); | ||
// cout << "right = " << right.average << right.stddev << endl; | ||
if (!is_black(right, MAX_SUM, MAX_STDDEV)){ | ||
return false; | ||
} | ||
// ImageStats body = image_stats(extract_box_reference(screen, m_body)); | ||
// cout << "body = " << body.average << body.stddev << endl; | ||
// if (is_black(right, 30, 30)){ | ||
// return false; | ||
// } | ||
|
||
|
||
// for (int c = 0; c < screen.width(); c++){ | ||
// QRgb pixel = screen.pixel(c, 0); | ||
// cout << "(" << qRed(pixel) << "," << qGreen(pixel) << "," << qBlue(pixel) << ")"; | ||
// } | ||
|
||
return true; | ||
} | ||
|
||
|
||
} |
34 changes: 34 additions & 0 deletions
34
SerialPrograms/Source/CommonFramework/Inference/BlackBorderGBADetector.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* Black Screen Detector | ||
* | ||
* From: https://github.com/PokemonAutomation/Arduino-Source | ||
* | ||
*/ | ||
|
||
#ifndef PokemonAutomation_CommonFramework_BlackBorderGBADetector_H | ||
#define PokemonAutomation_CommonFramework_BlackBorderGBADetector_H | ||
|
||
#include "CommonFramework/ImageTools/ImageBoxes.h" | ||
#include "CommonFramework/Inference/VisualDetector.h" | ||
|
||
namespace PokemonAutomation{ | ||
|
||
|
||
class BlackBorderGBADetector : public StaticScreenDetector{ | ||
public: | ||
BlackBorderGBADetector(); | ||
|
||
virtual void make_overlays(VideoOverlaySet& items) const override; | ||
virtual bool detect(const ImageViewRGB32& screen) const override; | ||
|
||
private: | ||
ImageFloatBox m_top; | ||
ImageFloatBox m_bottom; | ||
ImageFloatBox m_left; | ||
ImageFloatBox m_right; | ||
// ImageFloatBox m_body; | ||
}; | ||
|
||
|
||
|
||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
SerialPrograms/Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* Dialog Detector | ||
* | ||
* From: https://github.com/PokemonAutomation/Arduino-Source | ||
* | ||
*/ | ||
|
||
#include "CommonFramework/ImageTools/SolidColorTest.h" | ||
#include "CommonFramework/ImageTools/ImageBoxes.h" | ||
#include "CommonFramework/ImageTools/ImageFilter.h" | ||
#include "CommonFramework/ImageTypes/ImageRGB32.h" | ||
#include "CommonFramework/ImageTools/ImageStats.h" | ||
#include "CommonFramework/ImageTypes/ImageViewRGB32.h" | ||
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" | ||
#include "PokemonRSE_DialogDetector.h" | ||
|
||
#include <iostream> | ||
using std::cout; | ||
using std::endl; | ||
|
||
namespace PokemonAutomation{ | ||
namespace NintendoSwitch{ | ||
namespace PokemonRSE{ | ||
|
||
/* | ||
DialogDetector::DialogDetector(Color color) | ||
: m_left_box(0.155, 0.727, 0.015, 0.168) | ||
, m_right_box(0.837, 0.729, 0.008, 0.161) | ||
{} | ||
void DialogDetector::make_overlays(VideoOverlaySet& items) const{ | ||
items.add(COLOR_RED, m_left_box); | ||
items.add(COLOR_RED, m_right_box); | ||
} | ||
bool DialogDetector::detect(const ImageViewRGB32& screen) const{ | ||
ImageViewRGB32 left_image = extract_box_reference(screen, m_left_box); | ||
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); | ||
if (is_solid(left_image, { 0.335, 0.331, 0.332 }) && is_solid(right_image, { 0.335, 0.331, 0.332 })){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
*/ | ||
|
||
BattleDialogDetector::BattleDialogDetector(Color color) | ||
: m_left_box(0.158, 0.725, 0.011, 0.176) | ||
, m_right_box(0.827, 0.722, 0.013, 0.178) | ||
{} | ||
void BattleDialogDetector::make_overlays(VideoOverlaySet& items) const{ | ||
items.add(COLOR_RED, m_left_box); | ||
items.add(COLOR_RED, m_right_box); | ||
} | ||
bool BattleDialogDetector::detect(const ImageViewRGB32& screen) const{ | ||
ImageViewRGB32 left_image = extract_box_reference(screen, m_left_box); | ||
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); | ||
if (is_solid(left_image, { 0.335, 0.331, 0.332 }) && is_solid(right_image, { 0.335, 0.331, 0.332 })){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
|
||
BattleMenuDetector::BattleMenuDetector(Color color) | ||
: m_left_box(0.439, 0.717, 0.021, 0.192) | ||
, m_right_box(0.821, 0.725, 0.030, 0.181) | ||
{} | ||
void BattleMenuDetector::make_overlays(VideoOverlaySet& items) const{ | ||
items.add(COLOR_RED, m_left_box); | ||
items.add(COLOR_RED, m_right_box); | ||
} | ||
bool BattleMenuDetector::detect(const ImageViewRGB32& screen) const{ | ||
ImageViewRGB32 left_image = extract_box_reference(screen, m_left_box); | ||
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box); | ||
if (is_solid(left_image, { 0.335, 0.331, 0.332 }) && is_solid(right_image, { 0.25, 0.38, 0.369 })){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
|
||
AdvanceDialogDetector::AdvanceDialogDetector(Color color) | ||
: m_dialog_box(0.156, 0.715, 0.686, 0.193) | ||
{} | ||
void AdvanceDialogDetector::make_overlays(VideoOverlaySet& items) const{ | ||
items.add(COLOR_RED, m_dialog_box); | ||
} | ||
bool AdvanceDialogDetector::detect(const ImageViewRGB32& screen) const{ | ||
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; | ||
*/ | ||
|
||
if ((stats.average.r > stats.average.b + 200) && (stats.average.r > stats.average.g + 200)){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
|
||
|
||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to pull this out into a separate PR so it can go in earlier.