I have try using matchTemplate() function and minMaxLoc() function to find position image in another image but it not working because the container image it not same angle with the image I find.
This is I have done with origin image and it work fine with matchTemplate() function and minMaxLoc(). But if I rotate image. Nothing is recognize.
This is code I using to recognize coin:
img_rgb = cv.imread('mario.png')
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
template = cv.imread('mario_coin.png',0)
w, h = template.shape[::-1]
res = cv.matchTemplate(img_gray,template,cv.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
cv.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)
cv.imwrite('res.png',img_rgb)
My image rotate 30 degree:
Can anyone help me with this ?