-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_moving_box.py
96 lines (86 loc) · 3.06 KB
/
generate_moving_box.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
from random import randint
from poseModel.Node import Node
from poseModel.Person import Person
from poseModel.Pose import Pose
def loadPersonOne():
file = open("/data/person1Frame.txt", 'r')
# currWin = None
person = Person()
poseSequence = []
count = 0
index = 0
poseSequence.append(Pose())
for line in file:
if "#" in line:
poseSequence[index].Normalize(10)
poseSequence.append(Pose())
count = 0
index += 1
else:
x, y, con = line.split(" ")
node = Node(count, int(x), int(y), con)
poseSequence[index].addNode(node)
count += 1
person.addPoseSequence(poseSequence)
# currWin = GraphWin("window", 1000, 1000)
# for poseIndex in person.getPoseSequence():
# currWin = GraphWin("window", 1000, 1000)
# for node in poseIndex.getNormalizedPoseNodes():
# circle = Circle(Point(node.getX(), node.getY()), 3)
# circle.setFill("red")
# circle.draw(currWin)
# currWin.getMouse()
file.close()
return person
out = open("/data/out.txt","w")
start_position = (0,0)
box_width_height = (10,10)
moving_speed = 10
gap = 1
# Write the first data
out.write("{} {} {} {} {}\n".format(0,start_position[0],start_position[1],box_width_height[0],box_width_height[1]))
# Generate horizontal moving box
loop_p = start_position
for i in range(1,11):
moving_speed = randint(10,20)
(tmp_x,tmp_y) = loop_p
tmp_x += moving_speed + gap
person = loadPersonOne()
currPose = person.getPoseSequence()[i % len(person.getPoseSequence())]
outputStr = "0 " + "frame" + str(i) + " "
for node in currPose.getPoseNodes():
node.normalize(-tmp_x, -tmp_y, 5)
outputStr += str(node.getX()) + " " + str(node.getY()) + " " + str(node.getConfidence()) + " "
out.write(outputStr + "\n")
loop_p = (tmp_x,tmp_y)
# Generate vertical moving box
loop_p = start_position
for i in range(1,11):
moving_speed = randint(10,20)
(tmp_x,tmp_y) = loop_p
tmp_y += moving_speed + gap
person = loadPersonOne()
currPose = person.getPoseSequence()[i % len(person.getPoseSequence())]
outputStr = "1 " + "frame" + str(i) + " "
for node in currPose.getPoseNodes():
node.normalize(-tmp_x, -tmp_y, 5)
outputStr += str(node.getX()) + " " + str(node.getY()) + " " + str(node.getConfidence()) + " "
out.write(outputStr + "\n")
loop_p = (tmp_x, tmp_y)
# Generate diagonal moving box
moving_speed = 14
loop_p = start_position
for i in range(1,11):
moving_speed = randint(14,20)
(tmp_x,tmp_y) = loop_p
tmp_x += moving_speed + gap
tmp_y += moving_speed + gap
person = loadPersonOne()
currPose = person.getPoseSequence()[i % len(person.getPoseSequence())]
outputStr = "2 " + "frame" + str(i) + " "
for node in currPose.getPoseNodes():
node.normalize(-tmp_x, -tmp_y, 5)
outputStr += str(node.getX()) + " " + str(node.getY()) + " " + str(node.getConfidence()) + " "
out.write(outputStr + "\n")
loop_p = (tmp_x, tmp_y)
out.close()