-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLearning.py
41 lines (33 loc) · 1.35 KB
/
Learning.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
import math
#Receiving number of photos that we are going to learn
picture_count = int(input("Picture count of directory: "))
#Cycling through points
for ctr in range(picture_count):
#Reading points from data(k).txt
listFile = open('./point/points{}.txt'.format(ctr),'r')
file = listFile.read()
lines = list(file.split("\n"))
points_index = []
x_pos = []
y_pos = []
for i in range(len(lines) - 1):
cleanedRow = list(lines[i].split(','))
cleanedRow[-1] = cleanedRow[-1].replace('\n','')
points_index.append(int(cleanedRow[0]))
x_pos.append(int(cleanedRow[1]))
y_pos.append(int(cleanedRow[2]))
listFile.close()
fasele = [[0] * 68] * 68
#Save corresponding distance in fasele(p).txt
listFile = open('./fasele/fasele{}.txt'.format(ctr),'w')
for i in range(68):
for j in range(68):
#Calculating corresponding distance
fasele[i][j] = int(math.sqrt(((x_pos[i] - x_pos[j]) ** 2) + ((y_pos[i] - y_pos[j]) ** 2)))
listFile.write(str(fasele[i][j]) + "\n")
listFile.close()
#Save corresponding feelings in feeling(p).txt
feeling = input("whats the feeling for image {}?".format(ctr))
listfile = open('./feeling/feeling{}.txt'.format(ctr),'w')
listfile.write(feeling)
listfile.close()