timotheeg / nestrischamps

A web-based OCR and restreamer system for NES Classic Tetris players
MIT License
48 stars 11 forks source link

Only apply shine optimization to levels x6 x7 only #57

Closed timotheeg closed 3 years ago

timotheeg commented 3 years ago

Context

On some capture cards, interlacing artifacts can be incorrectly detected as block shine, and while the block color is never matched against the black, picking the darkest color instead.

The shine optimization is needed for levels x6 and x7 on retron because the colors is so close to black that block detection is unreliable for them, and the shine is a better approach.

Approach

alex-ong commented 3 years ago

Might as well skip shine detection for the other levels then? Save some cycles

timotheeg commented 3 years ago

Might as well skip shine detection for the other levels then? Save some cycles

I thought about that, but I reasoned keeping the shine detection might still help overall. Exiting early on black blocks still applies for the top part of the board and for at least one hole per row for the bottom part.

So there's a threshold number of blocks where the early exit is no longer beneficial, but I haven't done the math to figure out what the threshold is, to check it i's really worth keeping.

Also, I kept the shine check to keep the PR small, and to not have to make scanField() aware of the level. That one is a rather lousy reason though, the one above is better.

I will probably do the math ... sometimes 😅