Skip to content

add BDSP blink detection - #1378

Merged
Mysticial merged 3 commits into
PokemonAutomation:mainfrom
theastrogoth:bdsp-blink-detection
Aug 13, 2026
Merged

add BDSP blink detection#1378
Mysticial merged 3 commits into
PokemonAutomation:mainfrom
theastrogoth:bdsp-blink-detection

Conversation

@theastrogoth

@theastrogoth theastrogoth commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Adds a few things related to blink detection:

  • a way to set set the detection box and choose appropriate image templates depending on the scene (at Lake Verity, in the player character's bedroom, etc)
  • a blink detector
    • converts template and capture to grayscale to mitigate in-game time of day differences or capture card hue differences
    • matches the template to the capture by searching across the detection box, which is big enough to allow for idle animations, and calculating cross-correlation
    • stores scores and timestamps in a vector to be used later to decide when blinks occurred (blinking increases the difference of the capture from the template for a few frames)
  • a UI option for selecting one of the 8 character models (for template selection)

double best = -1.0;

for (size_t dy = 0; dy + m_height <= region_height; dy++){
for (size_t dx = 0; dx + m_width <= region_width; dx++){

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave a comment here explaining the math here? I see a variance calculation, though I can't tell how similar it is to the image_stats() function or if it duplicates it entirely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally avoided image_stats to work in grayscale rather than RGB, but just using OpenCV's matchTemplate() instead of basically reimplementing it is probably the best option

}
return {
BdspEyeTemplate{
"lake_templates/model" + std::to_string(player_model) + ".png",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already merged the Packages PR for this, but can be change the naming convention to:
LakeTemplates/Model-X.png? (title case)

@theastrogoth
theastrogoth marked this pull request as draft August 12, 2026 18:10
@theastrogoth
theastrogoth marked this pull request as ready for review August 13, 2026 01:08
@Mysticial
Mysticial merged commit 905cdb1 into PokemonAutomation:main Aug 13, 2026
7 checks passed
@theastrogoth
theastrogoth deleted the bdsp-blink-detection branch August 13, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants