Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group rectangles #10

Closed
antofa opened this issue Feb 11, 2022 · 6 comments
Closed

Group rectangles #10

antofa opened this issue Feb 11, 2022 · 6 comments

Comments

@antofa
Copy link

antofa commented Feb 11, 2022

изображение

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
Copy link
Owner

4rtzel commented Feb 11, 2022

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
Copy link
Author

antofa commented Feb 11, 2022

изображение

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
Copy link
Owner

4rtzel commented Feb 11, 2022

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

@4rtzel
Copy link
Owner

4rtzel commented Feb 11, 2022

@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
Copy link
Author

antofa commented Feb 11, 2022

@4rtzel perfect, it works without errors

@4rtzel
Copy link
Owner

4rtzel commented Feb 12, 2022

This issue is resolve. Closing.

@4rtzel 4rtzel closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants