(mat_file)
return match_ret
Read .mat file and read matches
    
    Arguments:
        mat_file {str} -- .mat file
    
    Returns:
        A list of tuples with each of format (second_sift_name (without .sift suffix), 
        match_num (putative, hinlier, finlier), homograph matrix, fundamental matrix,
        match pairs (list of (feat1, feat2, flag)))
Read .mat file and read matches
    
    Arguments:
        mat_file {str} -- .mat file
    
    Returns:
        A list of tuples with each of format (second_sift_name (without .sift suffix), 
        match_num (putative, hinlier, finlier), homograph matrix, fundamental matrix,
        match pairs (list of (feat1, feat2, flag)))
Read . mat file and read matches Arguments : mat_file { str } -- . mat file Returns : A list of tuples with each of format ( second_sift_name ( without . sift suffix ) match_num ( putative hinlier finlier ) homograph matrix fundamental matrix match pairs ( list of ( feat1 feat2 flag )))
def read_match_repo(mat_file):
    """Read .mat file and read matches
    
    Arguments:
        mat_file {str} -- .mat file
    
    Returns:
        A list of tuples with each of format (second_sift_name (without .sift suffix), 
        match_num (putative, hinlier, finlier), homograph matrix, fundamental matrix,
        match pairs (list of (feat1, feat2, flag)))
    """

    match_ret = []
    with open(mat_file, 'rb') as fin:
        data = fin.read()
        if len(data) == 0:
            return match_ret
        file_end = len(data)

        end = 0
        while True:
            # read filename length
            length_bytes = 4
            length = data[end:end+length_bytes]
            length = unpack('i', length)[0]
            end += length_bytes

            # read filename
            filename_bytes = length
            filename = data[end:end+filename_bytes]
            filename = unpack('c' * length, filename)
            sift_name2 = os.path.splitext(''.join(filename))[0]
            end += filename_bytes

            # read match number (putative, hinlier, finlier)
            match_num_bytes = 4 * 3
            match_num = data[end:end+match_num_bytes]
            match_num = unpack('3i', match_num)
            end += match_num_bytes

            # read homograph (3x3) and fundamental matrix (3x3)
            mat_bytes = 8 * 18
            mat = data[end:end+mat_bytes]
            mat = unpack('18d', mat)
            hmat = mat[:9]
            fmat = mat[9:]
            hmat = np.matrix([hmat[:3],hmat[3:6],hmat[6:9]], dtype=np.float32)
            fmat = np.matrix([fmat[:3],fmat[3:6],fmat[6:9]], dtype=np.float32)
            end += mat_bytes

            # read actual match (sift feature index pairs)
            struct_bytes = 12 * match_num[0]
            struct = data[end:end+struct_bytes]
            struct = unpack(match_num[0] * '3i', struct)
            struct = np.reshape(struct, (-1, 3))
            end += struct_bytes

            match_ret.append((sift_name2, match_num, hmat, fmat, struct))
            if end == file_end:
                break
    return match_ret
def read_match_repo ( mat_file ) : match_ret = [ ] with open ( mat_file , 'rb' ) as fin : data = fin . read ( ) if len ( data ) == 0 : return match_ret file_end = len ( data ) end = 0 while True : # read filename length length_bytes = 4 length = data [ end : end + length_bytes ] length = unpack ( 'i' , length ) [ 0 ] end += length_bytes # read filename filename_bytes = length filename = data [ end : end + filename_bytes ] filename = unpack ( 'c' * length , filename ) sift_name2 = os . path . splitext ( '' . join ( filename ) ) [ 0 ] end += filename_bytes # read match number (putative, hinlier, finlier) match_num_bytes = 4 * 3 match_num = data [ end : end + match_num_bytes ] match_num = unpack ( '3i' , match_num ) end += match_num_bytes # read homograph (3x3) and fundamental matrix (3x3) mat_bytes = 8 * 18 mat = data [ end : end + mat_bytes ] mat = unpack ( '18d' , mat ) hmat = mat [ : 9 ] fmat = mat [ 9 : ] hmat = np . matrix ( [ hmat [ : 3 ] , hmat [ 3 : 6 ] , hmat [ 6 : 9 ] ] , dtype = np . float32 ) fmat = np . matrix ( [ fmat [ : 3 ] , fmat [ 3 : 6 ] , fmat [ 6 : 9 ] ] , dtype = np . float32 ) end += mat_bytes # read actual match (sift feature index pairs) struct_bytes = 12 * match_num [ 0 ] struct = data [ end : end + struct_bytes ] struct = unpack ( match_num [ 0 ] * '3i' , struct ) struct = np . reshape ( struct , ( - 1 , 3 ) ) end += struct_bytes match_ret . append ( ( sift_name2 , match_num , hmat , fmat , struct ) ) if end == file_end : break return match_ret