Hello I have an array of rectangles rect
that represent the bounding boxes for detected objects. Often, these rectangles overlap and I would like to merge all rectangles that are intersecting into one big rectangle (and have multiple rectangles on screen if there are two separate clusters for example). Is there a way to do this?
I have already tried cv2.groupRectangles(rect, 1, .5)
, but clusters of rectangles are grouped into one rectangle in the middle that is the same size as the original rectangles.
EDIT:
Here is the pic without grouping:
Here is the pic with grouping and the method described below
To clarify a little more about what I am looking for I would just want red boxes over the individual blocks (Or ideally one box over the entire row), instead of in the middle, just so can condense the amount of boxes that I need to do computations for to speed up the program