4rtzel / poe-archnemesis-scanner

Tool for Path of Exile game to automatically scan Archemesis inventory and display related information
Apache License 2.0
64 stars 25 forks source link

Group rectangles #10

Closed antofa closed 2 years ago

antofa commented 2 years ago

изображение

16 berserkers found, but actually 7 is in inventory

Seems you don't group rectangles with cv2, do you?

For example:

def get_rectangles(image, template, THRESHOLD = 0.8):
    result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
    yloc, xloc = np.where(result >= THRESHOLD)

    rectangles = []

    [ht, wt] = template.shape
    for (x, y) in zip(xloc, yloc):
        rectangles.append([int(x), int(y), int(wt), int(ht)])
        rectangles.append([int(x), int(y), int(wt), int(ht)])

    rectangles, weights = cv2.groupRectangles(rectangles, 1, 0.1)

    return rectangles
4rtzel commented 2 years ago

Could you explain what does it do exactly?

As far as I understand, it should eliminate possible overlapping rectangles?

It's also interesting that it's first time I'm seeing the algorithm detects the same inventory item as multiple matches. Could you provide a little bit more info about your setup?

antofa commented 2 years ago

изображение

yes, it is for groupping close rectangles

изображение

windows 10, also i dont know what is correct scale rate for my window (1920x1040 paint says, but in poe 1920x1017)

4rtzel commented 2 years ago

The support for the windowed version should arrive soon. Hope it will help it your case.

4rtzel commented 2 years ago

@antofa, I've added the implementation for rectangle grouping in 65bb088. Could you please take a look and validate that the code is correct? After that, I'll close this issue.

antofa commented 2 years ago

@4rtzel perfect, it works without errors

4rtzel commented 2 years ago

This issue is resolve. Closing.