PokemonAutomation / Arduino-Source

MIT License
21 stars 57 forks source link

Update DialogArrowWatcher and DialogDetector #476

Closed jw098 closed 2 weeks ago

jw098 commented 2 weeks ago

Note: This is used by Autostory. So, I recommend merging this first.

DialogDetector: changed the stddev threshold to deal with light backgrounds.

DialogArrowWatcher: Nothing currently uses this, so I revamped it to meet my needs. The current ExactImageMatcher DIALOG_ARROW_WHITE() uses a template with a black background. This doesn’t work for me since I want to be able to detect the arrow on variable background colors. DialogArrowMatcher uses a template with no background. This does a good job of matching the arrow. But I worry about false positives with pure white templates. So, I made sure process_frame can detect the oscillation of the arrow, to reduce false positives. The way it detects the oscillations is by locating the position of the arrow, and incrementing m_num_oscillation_above_top_line every time the arrow is above top_line. Likewise for m_num_oscillation_below_bottom_line. We alternate between looking for the arrow being above top_line vs below bottom_line. Reset the counts whenever the dialog arrow is not detected.

For your reference, the DialogArrow that I'm trying to detect is seen in the bottom right of this screenshot.

screenshot-20240904-180610279507