Using Computer Vision to Win at Duck Hunt
blog.roboflow.com
blog.roboflow.com
Duck Hunt has only a few sprites, maybe four or six. It's really easy to just scan the whole image and match those sprites, exactly pixel-by-pixel. This doesn't really need anything that could reasonably be called machine learning or computer vision. Synthetic 8-bit images can be handled with 8-bit algorithms. We don't need much art and we certainly don't need its state either.
Why pick such an example to advertise roboflow?
The article itself also has pretty much no details on how Roboflow works. Not a single code sample! Just links to Roboflow docs.
This is blogspam.
However, if doing it with a classical approach (matching sprites) takes a person half a day, and doing it with the new fangled proprietary ml takes a person 20 minutes, I do see that doing it with the new fangled ml approach does have some merits. People want to get stuff done.
I'm a barely passable programmer, so not exactly a shining benchmark, so maybe my view is distorted. I don't think I can do duck detection flawlessly with classical programming in half a day and it would be a total pain in the ass to do it that way, to be completely honest with you.
This seems to be a case of "if you're holding a hammer, everything looks like a nail".
You can definitely do it in 20 minutes if you know how (which is also applicable to the ML version):
import cv2
import numpy as np
red_duck = cv2.imread("red_duck.png", cv2.IMREAD_GRAYSCALE)
# boilertplate etc, up to the point where you want to match your ducks on screen:
res = cv2.matchTemplate(img_screen, red_duck, cv2.TM_CCOEFF_NORMED)
positions = np.zeros_like(img_screen)
positions[res > 0.7] = 1 # we found a duck
# now do whatever you want with each position
# on real life images you may need to do some additional post-processing, on 8-bit rendered images you probably don't need toThere's no code in there. Just links to other articles and whatnot.
I vote for blogspam, too.
Sure it would work, but the phone also works and does way more. You might be able to use some trivial processing on duck hunt but it won't work on anything slightly more complex so why would you bother learning a method that only works on the most basic of games when you can develop something that can be applied everywhere.
Looking at the domain and the author, I'd say it was a straight-up advert
There are apparently after market mods and stuff that people have come up with to work around this, but it takes some effort.
As you can imagine I discovered this by trying to play duck hunt and being perplexed when I was literally unable to hit any target, which made a very poor demo for my kids haha.
This is obviously not a difficult CV problem. I don't want to disparage the post too much, though - the Roboflow tools to make this process accessible for a non-expert look very good, and it's a cool demo of those which is the real point of the blog.
> Roboflow's Dataset Health Check helped me
> I found Roboflow’s Model Library to be the best
> Roboflow would be my go-to platform
> Matt Brems, Growth Manager @ Roboflow
Please call this a demo or “how I use Roboflow to win a duck hunt”
> The user experience for preprocessing is amazing
Agreed, this was a bit over the top, but I could have improved my expectations by paying more attention to the domain name. :)
My choice of language was python with pywin32,numba and a screen duplication library which name I forgot. The biggest problem was that by the time I finished scanning the screenbuffer contents the enemies on screen have already moved.
If I had paid attention in university math classes I could've come up with a direction tracking and prediction system. :/
But then I threw the whole thing out the window and rewrote everything with good old fashioned readmemory()/writememory() :^)
The fonts are different, the UI is different and the UI elements are misaligned, the scenario is larger.
Edit: fixed!