(file_path)
return keypts, desc
Read feature file (*.sift).
Read feature file (*.sift).
Read feature file ( * . sift ) .
def read_feature_repo(file_path):
    """Read feature file (*.sift)."""
    with open(file_path, 'rb') as fin:
        data = fin.read()

    head_length = 20
    head = data[0:head_length]
    feature_name, _, num_features, loc_dim, des_dim = unpack('5i', head)
    keypts_length = loc_dim * num_features * 4

    if feature_name == ord('S') + (ord('I') << 8) + (ord('F') << 16) + (ord('T') << 24):
        print(Notify.INFO, 'Reading SIFT file',
              file_path, '#', num_features, Notify.ENDC)
        desc_length = des_dim * num_features
        desc_type = 'B'
    elif feature_name == 21384864:  # L2Net
        print(Notify.INFO, 'Reading L2NET file',
              file_path, '#', num_features, Notify.ENDC)
    else:
        print(Notify.FAIL, 'Unknown feature type.', Notify.ENDC)
        desc_length = des_dim * num_features * 4
        desc_type = 'f'

    keypts_data = data[head_length: head_length + keypts_length]
    keypts = np.array(unpack('f' * loc_dim * num_features, keypts_data))
    keypts = np.reshape(keypts, (num_features, loc_dim))

    desc_data = data[head_length +
                     keypts_length: head_length + keypts_length + desc_length]
    desc = np.array(unpack(
        desc_type * des_dim * num_features, desc_data))
    desc = np.reshape(desc, (num_features, des_dim))
    return keypts, desc
def read_feature_repo ( file_path ) : with open ( file_path , 'rb' ) as fin : data = fin . read ( ) head_length = 20 head = data [ 0 : head_length ] feature_name , _ , num_features , loc_dim , des_dim = unpack ( '5i' , head ) keypts_length = loc_dim * num_features * 4 if feature_name == ord ( 'S' ) + ( ord ( 'I' ) << 8 ) + ( ord ( 'F' ) << 16 ) + ( ord ( 'T' ) << 24 ) : print ( Notify . INFO , 'Reading SIFT file' , file_path , '#' , num_features , Notify . ENDC ) desc_length = des_dim * num_features desc_type = 'B' elif feature_name == 21384864 : # L2Net print ( Notify . INFO , 'Reading L2NET file' , file_path , '#' , num_features , Notify . ENDC ) else : print ( Notify . FAIL , 'Unknown feature type.' , Notify . ENDC ) desc_length = des_dim * num_features * 4 desc_type = 'f' keypts_data = data [ head_length : head_length + keypts_length ] keypts = np . array ( unpack ( 'f' * loc_dim * num_features , keypts_data ) ) keypts = np . reshape ( keypts , ( num_features , loc_dim ) ) desc_data = data [ head_length + keypts_length : head_length + keypts_length + desc_length ] desc = np . array ( unpack ( desc_type * des_dim * num_features , desc_data ) ) desc = np . reshape ( desc , ( num_features , des_dim ) ) return keypts , desc