qis / horus

OBS plugin for Overwatch enemy detection using OpenCV and CUDA
Boost Software License 1.0
23 stars 3 forks source link

Creating polygons using convex hulls and outlines. #1

Open qis opened 1 year ago

qis commented 1 year ago

The goal is to create polygons as a close approximation of an object that is restricted to a convex hull and has a known set of disconnected outlines.

This image demonstrates problems with previous attempts.

  1. Single pixels can be easily removed before connecting the outlines, but can degrade the approximation quality.
  2. Connecting two outline endpoints that are closest to each other can fail because of unwanted outlines inside the object.
  3. Connecting all outline endpoints that have no outline pixels between them fails due to random endpoint orientation.
  4. Applying the OpenCV "close" morphology filter removes a lot of detail, since it does not work with outline endpoints.
  5. Reducing the hull using a large brush would loose a lot of detail or slip through the gaps if the brush is too small.

mask

qis commented 1 year ago

@drkostas Not sure how you found this project, but since you're watching it, I hope it's OK that I tag you here.

Have you encountered a similar problem or do you have any ideas how to solve it?

qis commented 1 year ago

For now, the hull will be eroded until it meets the outline. The result isn't very good, but seems to work.

8-shapes 9-polygons

Still searching for a better solution or ways to improve the current one.