-
Notifications
You must be signed in to change notification settings - Fork 31
/
outputs.py
36 lines (29 loc) · 939 Bytes
/
outputs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# coding: utf-8
# Imports
import numpy as np
import os
# Call function saveKeypointsAndDescriptors
def saveKeypointsAndDescriptors(keypoints,
descriptors,
matcher,
descriptor,
flags):
# flags = 1: input image or queryDescriptors
# flags = 2: training-set image trainDescriptors
# File name
filename1 = 'Outputs/%s-with-%s-keypoints%s.txt' % (matcher, descriptor, flags)
filename2 = 'Outputs/%s-with-%s-descriptors%s.txt' % (matcher, descriptor, flags)
# Delete a file if it exists
if os.path.exists(filename1):
os.remove(filename1)
elif os.path.exists(filename2):
os.remove(filename2)
# Save keypoints into a file
np.savetxt(fname = filename1,
X = keypoints,
fmt='%s')
# Save descriptors into a file
np.savetxt(fname = filename2,
X = descriptors,
fmt = "%d")