2

I've been following a tutorial for developing a template matching bot for the flash game Burrito Bison, github with code linked here but even with the original source code can't seem to get the bot to run. The error appears to be with the line res = cv2.matchTemplate(img_grayscale, template, cv2.TM_CCOEFF_NORMED) in the file vision.py

The full error is cv2.error: OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\imgproc\src\templmatch.cpp:589: error: (-215:Assertion failed) corrsize.height <= img.rows + templ.rows - 1 && corrsize.width <= img.cols + templ.cols - 1 in function 'cv::crossCorr'

Haven't tried much, I've never worked with OpenCV before and this is quite new to me.

def match_template(self, img_grayscale, template, threshold=0.9):
    """ Matches template image in a target grayscaled image """

    res = cv2.matchTemplate(img_grayscale, template, cv2.TM_CCOEFF_NORMED)
    matches = np.where(res >= threshold)

Expected result is it working properly and playing the game.

Joe Howard
  • 307
  • 5
  • 27
  • Possible duplicate of [cvMatchTemplate() function giving assertion failed error? opencv](https://stackoverflow.com/questions/6083625/cvmatchtemplate-function-giving-assertion-failed-error-opencv) – Edeki Okoh Jan 30 '19 at 23:40

0 Answers0