def find_polygons(gray_image_in, edge_num, tolerance=0.1, area_threshold=100, convex_only=True, edge_threshold=60, orientation=1.0):
    img = gray_image_in.copy()
    lo, hi = 100, 150
    
    # cv2.imshow('img', img)
    edge = cv2.Canny(img, lo, hi)
    # imshow('edge', edge)
    thresh1, dst = cv2.threshold(edge,edge_threshold,255, cv2.THRESH_BINARY)
    # imshow('thresh', dst)
    ctr, hry = cv2.findContours(dst, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    # cv2.imshow('fndctr', dst)
    
    if hry is None: return []
    hry = hry[0]
    
    polygons = []
    for cnt in ctr:

        # kill the contour if it doesn't look like a square
        cnt = cnt.reshape(-1,2)
        epsilon = tolerance * 2 * ((3.14 * cv2.contourArea(cnt)) ** 0.5)
        tmp = cv2.approxPolyDP(cnt,epsilon,True)

        if len(tmp) != edge_num: continue
        if convex_only and not cv2.isContourConvex(tmp): continue 
        if cv2.contourArea(tmp) < area_threshold: continue
        
        # now sort the points in counter clock wise so we can eliminate similar solutions
        cross_product = np.cross(tmp[1] - tmp[0], tmp[2] - tmp[1])[0]
        if cross_product * orientation > 0:
            tmp = np.flipud(tmp)
        
        # rearrange the points so that the returned point array always start with
        # the point that is closest to origin
        tmp = tmp.reshape(-1,2)
        distance_from_origin = map(lambda pt: pt[0] ** 2 + pt[1] ** 2, tmp)
        val, idx = min((val, idx) for (idx, val) in enumerate(distance_from_origin))
        
        if idx > 0:
            up, down = np.vsplit(tmp, [idx])
            tmp = np.vstack((down, up))
        
        polygons.append(tmp)
    
    return polygons
Calculate the default volume size for the given dataset backend
dataset/ETHPy150Open fatcloud/PyCV-time/experiments/differential_screen_tracker/find_polygons.py/find_polygons--crossover with--dataset/ETHPy150Open ClusterHQ/flocker/admin/acceptance.py/get_default_volume_size