-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathVLADtoCSV.py
49 lines (39 loc) · 1021 Bytes
/
VLADtoCSV.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
46
47
48
49
#write to csv
# Jorge Guevara
from VLADlib.VLAD import *
from VLADlib.Descriptors import *
import pickle
import argparse
import glob
import cv2
import csv
#parser
ap = argparse.ArgumentParser()
ap.add_argument("-d", "--path", required = True,
help = "Path to VLAD descritpors")
ap.add_argument("-o", "--output", required = True,
help = "Path of csv")
args = vars(ap.parse_args())
#args
path = args["path"]
output = args["output"]
with open(path, 'rb') as f:
VLAD_DS=pickle.load(f)
imageID=VLAD_DS[0]
print(imageID)
V=VLAD_DS[1]
l =len(imageID)
print(l)
print(V.shape)
with open(output, 'w') as f:
#writer=csv.writer(f)
for i in range(l):
#writer.writerow([imageID[i],V[i]])
features = [str(fs) for fs in V[i]]
f.write("%s,%s\n" % (imageID[i], ",".join(features)))
#for im in imageID:
# writer.writerow([im,V])
#thedatawriter = csv.writer(mycsvfile, dialect='mydialect')
#for row in arrayofdata:
# thedatawriter.writerow(row)