4 Create sift feature dataset from assigned images. 21 container_folder_sift_feature.pkl.gz 33 from sklearn.datasets.base
import Bunch
34 from sklearn.datasets
import load_files
38 parser = argparse.ArgumentParser()
39 parser.add_argument(
'container_path', help=
'image data container path')
40 parser.add_argument(
'-O',
'--output', default=
None, help=
'output file')
41 args = parser.parse_args()
43 container_path = args.container_path
44 output = (args.output
or 45 os.path.basename(container_path) +
'_sift_feature.pkl.gz')
48 bunch_files = load_files(container_path=container_path,
49 description=
'image data',
53 targets, pos_list, scale_list, ori_list, desc_list = [], [], [], [], []
54 for i, (filename, target)
in enumerate(zip(bunch_files.filenames,
56 print((
'filename: {}, label: {}'.format(filename, target)))
57 targets.append(target)
59 img = cv2.imread(filename, 0)
62 pos_list.append(np.hstack([frames[:, 0], frames[:, 1]]))
63 ori_list.append(frames[:, 2])
64 scale_list.append(frames[:, 3])
65 desc_list.append(desc)
67 dataset = Bunch(target=np.array(targets),
68 target_names=bunch_files.target_names,
71 orientations=ori_list,
72 descriptors=desc_list)
75 print(
'saving sift feature dataset')
76 with gzip.open(output,
'wb')
as f:
77 pickle.dump(dataset, f)
80 if __name__ ==
'__main__':
def create_sift_dataset()
def get_sift_keypoints(img)