def test_detect_englobing_polygon_photo(): array = _image('sheet.jpg') points = detect_englobing_polygon(array).astype(int) assert len(points) == 4 area = cv2.contourArea(points) points = [(p[0, 0], p[0, 1]) for p in points] h, w = get_target_rectangle_size(points) assert h * w > (array.shape[0] * array.shape[1])* 1 / 3 assert w > array.shape[0]/2 assert h > array.shape[1]/2 assert h * w > area
def test_get_target_rectangle_size(): test_case = ((0, 0), (1, 0), (0.5, 0.5), (0, 1)) assert (1, 1) == get_target_rectangle_size(test_case) nparray = np.array(test_case, dtype='float') assert (1, 1) == get_target_rectangle_size(nparray)