#contours=[[[ ],[ ] ],[ ],[ ],[ ]]
for i in contours:
rect = cv2.minAreaRect(i)# 得到最小外接矩形的(中心(x,y), (宽,高), 旋转角度)
box = cv2.boxPoints(rect)# 获取最小外接矩形的4个顶点坐标(ps: cv2.boxPoints(rect) for OpenCV 3.x)
box = np.int0(box)
# 画出来
cv2.drawContours(img, [box],0, (255,0,0),1)