Here is the error message:

error: (-215:Assertion failed) (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 in function 'cv::matchTemplate'

This is the function that the error occurred in, in line result = cv.matchTemplate(biome_img, self.husk_image, self.method)

def find(self, biome_img, threshold=0.5, debug_mode=None):
    result = cv.matchTemplate(biome_img, self.husk_image, self.method)

    locations = np.where(result >= threshold)
    locations = list(zip(*locations[::-1]))

    rectangles = []
    for loc in locations:
        rect = [int(loc[0]), int(loc[1]), self.img_w, self.img_h]

        rectangles.append(rect)
        rectangles.append(rect)

    rectangles, weights = cv.groupRectangles(rectangles, groupThreshold=1, eps=0.5)

This is how I called the function:

while True:
    screenshot = wincap.window_capture()
    points = visionObject.find(screenshot, 0.5, 'rectangles')

I've tried changing them to uint8 and float32 but it didn't work.

0

There are 0 best solutions below