39 lines
1.0 KiB
Python
Executable File
39 lines
1.0 KiB
Python
Executable File
from pathlib import Path
|
|
import tqdm
|
|
|
|
import LFUtilities
|
|
import ORBExtractor as lf
|
|
import argparse
|
|
import os
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser(description='LF bulk extraction')
|
|
parser.add_argument('src', type=str, help='img src folder path')
|
|
parser.add_argument('dest', type=str, help='lf dest folder')
|
|
|
|
args = parser.parse_args()
|
|
src = args.src
|
|
dest = args.dest
|
|
|
|
paths = Path(src).rglob('*.*')
|
|
paths_list = list(paths)
|
|
|
|
dataset = []
|
|
|
|
print('Extracting lf...')
|
|
for path in tqdm.tqdm(paths_list):
|
|
try:
|
|
kp, des = lf.extract(os.path.join(path.parent, path.name))
|
|
dataset.append((kp, des))
|
|
except:
|
|
print("cannot process '%s'" % path)
|
|
pass
|
|
|
|
LFUtilities.save(dataset, os.path.join(dest, 'dataset_lf.dat'))
|
|
with open(os.path.join(dest, 'dataset_lf.ids'), 'w') as f:
|
|
for path in paths_list:
|
|
id, _ = os.path.splitext(path.name)
|
|
f.write("%s\n" % id)
|
|
print('lf extracted.')
|