I am trying to detect boxes around objects (canny extracted contours) and sometimes an object would be read as 2 boxes instead of one. No big deal really, except for the fact that I am trying to count those objects. So, I’d like to combine boxes that are overlapping/nearby.
That’s what I’ve been trying so far:
minRect = [None]*len(contours) for i, c in enumerate(contours): minRect[i] = cv2.minAreaRect(c) minRect, _ = cv2.groupRectangles(minRect, 0)
This throws an error, and I understand why - a rotated rectangle (
minAreaRect output) is not something
groupRectangles expects. How can I ‘feed’ a rotated rectangle to
groupRectangles ? I’ve tried silly things like ripping out coordinates+measurements, and more reasonable things such as
boxPoints . I’ve looked through SO, and OpenCV docs (even some of sources) but couldn’t find anything to answer my question.