(surface, matrix, mm_x, mm_y, mm_width, mm_height)
return matrix_from_corners_2d(corners, mm_x, mm_y, mm_width, mm_height)
Detect the transformation matrix

    This runs a detection for the corner marks that denote the bounding box
    given by mm_x, mm_y, mm_width, mm_height in the surface. The passed matrix
    is used for to estimate the resolution of the image.

    This function returns a new cairo matrix or raises an error otherwise.
Detect the transformation matrix
Detect the transformation matrix
def calculate_matrix(surface, matrix, mm_x, mm_y, mm_width, mm_height):
    """Detect the transformation matrix

    This runs a detection for the corner marks that denote the bounding box
    given by mm_x, mm_y, mm_width, mm_height in the surface. The passed matrix
    is used for to estimate the resolution of the image.

    This function returns a new cairo matrix or raises an error otherwise.
    """
    found_corners = 0

    corners = []

    for i in (1, 2, 3, 4):
        try:
            corners.append(find_corner_marker (surface, matrix, i))
            found_corners += 1
        except:
            corners.append(None)

    # We need at least 3 corners to do anything
    assert found_corners >= 3

    return matrix_from_corners_2d(corners, mm_x, mm_y, mm_width, mm_height)
def calculate_matrix ( surface , matrix , mm_x , mm_y , mm_width , mm_height ) : found_corners = 0 corners = [ ] for i in ( 1 , 2 , 3 , 4 ) : try : corners . append ( find_corner_marker ( surface , matrix , i ) ) found_corners += 1 except : corners . append ( None ) # We need at least 3 corners to do anything assert found_corners >= 3 return matrix_from_corners_2d ( corners , mm_x , mm_y , mm_width , mm_height )