by jimmies · 5y ago · 0 comments
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 to