Finding clusters of detected min area rectangles

asked 2018-04-15 10:07:50 -0600

Tars gravatar image

I have 60ish objects in an image that I detected minarerect's for and I'd like to find clusters of similarly angled rectangles within a certain distance threshold of each other. I looked into kmeans a little, and I'm still kind of confused about the approach, but I'm pretty sure that kmeans isn't what I want to use since it needs me to tell it how many clusters I want to find, which is something I don't know.

As you can tell I'm new to opencv. I would appreciate any advice I can get from you all.

edit retag flag offensive close merge delete


I once used std::partitionfor it. Check the first answer here: You also have to let your boolean operator test, if the rectangles are similarly angled. Edit: An image would be nice for testing.

Grillteller gravatar imageGrillteller ( 2018-04-16 04:06:43 -0600 )edit

What you could do is something like put the areas in a vector. Then add the first value to a class, if the next one is less than 10% deviating add it to the same class, if not, start a new vector. For now each element has to be checked with the previous classes, before considering making a new one. The percentage can be your threshold on the seperation of classes.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-04-17 07:49:35 -0600 )edit