def find_contours(img):
'''
:param img: (numpy array)
:return: all possible rectangles (contours)
'''
img_blurred = cv2.GaussianBlur(img, (5, 5), 1) # remove noise
img_gray = cv2.cvtColor(img_blurred, cv2.COLOR_BGR2GRAY) # greyscale image
# cv2.imshow('', img_gray)
# cv2.waitKey(0)
# Apply Sobel filter to find the vertical edges
# Find vertical lines. Car plates have high density of vertical lines
img_sobel_x = cv2.Sobel(img_gray, cv2.CV_8UC1, dx=1, dy=0, ksize=3, scale=1, delta=0, borderType=cv2.BORDER_DEFAULT)
# cv2.imshow('img_sobel', img_sobel_x)
# Apply optimal threshold by using Oslu algorithm
retval, img_threshold = cv2.threshold(img_sobel_x, 0, 255, cv2.THRESH_OTSU + cv2.THRESH_BINARY)
# cv2.imshow('s', img_threshold)