1 | initial version |
untested, but you could add all the contour points to a single array, and call minAreaRect on it:
arr = []
for x,y,w,h in contourRects:
arr.append((x,y))
arr.append((x+w,y+h))
box = cv.minAreaRect(np.asarray(arr))
pts = cv.boxPoints(box) # 4 outer corners