-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreadRadiusData.py
135 lines (93 loc) · 3.01 KB
/
readRadiusData.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import json
def readDataR(myFile, writeToHere):
txt = open(str(myFile), "r")
written = open(str(writeToHere), "w")
data = txt.readlines()
txt.close()
for line in data:
cur = line.split()
string = '{"number":"' + cur[0] + '", "grTruth":"' + cur[1] + '", "src":"inputData/radius/' + cur[0] + '_TE_radius.jpg" },' + "' +\n"
string = "'" + string
written.write(string)
#print(string)
written.close()
def readDataT(myFile, writeToHere):
txt = open(str(myFile), "r")
written = open(str(writeToHere), "w")
data = txt.readlines()
txt.close()
for line in data:
cur = line.split()
string = '{"number":"' + cur[0] + '", "grTruth":"' + cur[1] + '", "src":"inputData/tibia/' + cur[0] + '_TE_tibia.jpg" },' + "' +\n"
string = "'" + string
written.write(string)
#print(string)
written.close()
def readSetDataR(myFile, writeToHere):
txt = open(str(myFile), "r")
written = open(str(writeToHere), "w")
data = txt.readlines()
txt.close()
first = True
for line in data:
cur = line.split()
string = cur[0]
if (string[len(string) - 1] == 'E'):
count = string[:len(string) - 1]
hello = "var set" + count + "TextTE =" + "'" + '{"imageNums":["dummy", ' #"20", "12", "56", "13", "23", "2", "24", "15"]}';
lineup = 1
else:
if (lineup == 8):
hello = hello + '"' + string + '"]}' + "';\n"
written.write(hello)
else:
hello = hello + '"' + string + '", '
lineup += 1
#print(string)
#written.write(string)
written.close()
""" writeToHere = file to write, topNum = yes, rOrT = string use 'radius' or 'tibia' """
def makeImgTxt(writeToHere, topNum, rOrT):
written = open(str(writeToHere), "w")
count = 1
while (count <= topNum):
myString = rOrT + "Images[" + str(count) + "] = new Image();\n"
written.write(myString)
myString = rOrT + "Images[" + str(count) + "].src = jsonTImages.tibiae[" + str(count) + "].src;\n"
written.write(myString)
count += 1
written.close()
""" var set1RT = JSON.parse(set1TextRT);"""
def parseSets(writeHere):
written = open(str(writeHere), "w")
i = 1
while (i < 16):
string = "var set" + str(i) + "TE = JSON.parse(set" + str(i) + "TextTE);\n"
written.write(string)
i += 1
written.close()
""" allSetsR[1] = set1RT; """
def declareSets(writeHere):
written = open(str(writeHere), "w")
i = 1
while (i < 16):
string = "allSetsRT[" + str(i) +"] = set" + str(i) + "RT;\n"
written.write(string)
i += 1
written.close()
""" read pixel info for MYFILE. NUMIMAGES is the number of images you have data for/want to read the data from. """
def readPixelInfo(myFile, writeHere):
txt = open(str(myFile), "r")
data = txt.readlines()
i = 0
while i < len(data):
data[i] = data[i].split()
i += 1
written = open(str(writeHere), "w")
written.write(json.dumps(data))
#readDataR("inputData/radius/groundTruth.txt", "jsonRtext.txt")
#readDataT("inputData/tibia/groundTruth.txt", "jsonTtext.txt")
#readSetDataR("inputData/tibia/setsEvaluation.txt", "temp.txt")
#parseSets("temp.txt")
#declareSets("temp.txt")
#makeImgTxt("temp.txt", 112, "tibia")