-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathread_data.py
45 lines (29 loc) · 1.21 KB
/
read_data.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
37
38
39
40
41
42
43
44
45
import glob,os
from params import get_params
def create_db_list(PATH,key):
print "Listing directory:", PATH
result = [y for x in os.walk(PATH) for y in glob.glob(os.path.join(x[0], key))]
return result
def create_shot_list(PATH):
shots = os.listdir(PATH)
return shots
if __name__ == "__main__":
params = get_params()
frames = create_db_list(params['database_images'],'*.jpg')
new_frames = []
if params['dataset'] is 'paris':
#remove corrupt images
for frame in frames:
if not os.path.basename(frame) in params['paris_corrupt_list']:
new_frames.append(frame)
frames = new_frames
print "Listed", len(frames), 'frames.'
print "Saving text file:", params['frame_list']
with open(params['frame_list'],'w') as outfile:
outfile.write("\n".join(frames))
# queries
queries = create_db_list(params['ground_truth_file'],"*query.txt")
print "Listed", len(queries), 'frames.'
print "Saving text file:", params['query_list']
with open(params['query_list'],'w') as outfile:
outfile.write("\n".join(queries))