alex-ong / NESTrisOCR

OCR for statistics in NESTris
24 stars 7 forks source link

Restore text stats #58

Closed timotheeg closed 4 years ago

timotheeg commented 4 years ago

⚠️ Merge #57 before checking this PR!

Restore naive piece stats OCR.

Other methods, relying on field inspection don't work well on twitch streams with varying quality, and frame drops. Piece stats are more "stable" for such cases.

Tested on OSX from a twitch stream.

@alex-ong @blakegong

timotheeg commented 4 years ago

Any objection if I set the stats OCR pattern to TDD rather than DDD? That implies counts up to 299 max for each piece type, which should be more than enough for any game, unless RNG gets you really really skewed distribution.

alex-ong commented 4 years ago

Any objection if I set the stats OCR pattern to TDD rather than DDD? That implies counts up to 299 max for each piece type, which should be more than enough for any game, unless RNG gets you really really skewed distribution.

No objection, i guess it gives a small perf boost.

alex-ong commented 4 years ago

Can you hook it to config so that we respect stats_method?

There are 3(?) methods: scanning text (this pr), check top of field (set a hook for it then raise unimplemented), None.

So in NAIVE if they set no-stats then we should setup the relevant task. It may be a good idea to subclass something that sorts this out. You can leave checking top of field as unimplemented for now.

timotheeg commented 4 years ago

Can you hook it to config so that we respect stats_method?

That's already done. I've only implemented the flow which starts with scan_stats_text(), which is already invoked by respecting the config:

        if config["stats.enabled"]:
            if config["stats.capture_method"] == "FIELD":
                tasks.append(self.scan_spawn)
            elif config["stats.capture_method"] == "TEXT":
                tasks.append(self.scan_stats_text)
alex-ong commented 4 years ago

Perfect!

Yeah i should have checked the code first, i was lazy :(

I think eventually i want to change from stats.enabled and stats.capture_method to stats.method and having "None" / "FIELD" / "TEXT" but that's an aside. I can merge now that you've put your TDD in?

timotheeg commented 4 years ago

I can merge now that you've put your TDD in?

Yes please 👍