`import cv2
img = cv2.imread('media/multi-rec.jpg') img = cv2.resize(img, (414, 732))
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges_high_thresh = cv2.Canny(image=gray, threshold1=60, threshold2=120) contours, _ = cv2.findContours(image=edges_high_thresh, mode=cv2.RETR_TREE, method=cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours: area = cv2.contourArea(cnt) peri = cv2.arcLength(curve=cnt, closed=True) approx = cv2.approxPolyDP(curve=cnt, epsilon=0.01*peri, closed=True) if area > 100 and len(approx) == 4: cv2.drawContours(image=img, contours=[approx], contourIdx=-1, color=(0, 255, 0), thickness=1)
cv2.imshow('Image edges', edges_high_thresh) cv2.waitKey(0) cv2.imshow('Image', img) cv2.waitKey(0)`