def shapeDetect(img):
contours,hierarchy=cv2.findContours(img,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(img,contours,-1,(0,0,255),3)
maxCnt=-1
for i in range(len(contours)):
rect = cv2.minAreaRect(contours[i])
box = np.int0(cv2.boxPoints(rect))
cv2.drawContours(img, [box], 0, (255, 255, 255), 2)
cv2.imshow('test.jpg',img)
cv2.waitKey(0)
转载请注明原文地址:https://ipadbbs.8miu.com/read-26000.html