1 | initial version |
Append all your rectangles in rectList and use cv2.boundingRect() to get the bigger rectangle that enclose all sub rectangles. Let me know if it works for you. Thanks berak's for the piece of code
arr = []
for x,y,w,h in rectList:
arr.append((x,y))
arr.append((x+w,y+h))
x,y,w,h = cv2.boundingRect(np.asarray(arr))
cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),1)