-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
60 lines (52 loc) · 1.35 KB
/
test.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
import tables
import cv2
import numpy as np
import time
filename = "D:\\rc car data collection\\second\\alldata\\train_data.h5"
# filename = 'test01436.h5'
# ROW_SIZE = 3
# NUM_COLUMNS = 200
# f = tables.open_file(filename, mode='w')
# atom = tables.Float64Atom()
#
# array_c = f.create_earray(f.root, 'data', atom, (0, ROW_SIZE))
#
# for idx in range(NUM_COLUMNS):
# x = np.random.rand(1, ROW_SIZE)
# print(x.shape)
# array_c.append(x)
# f.close()
# f = tables.open_file(filename, mode='a')
# f.root.data.append(x)
# f.close()
f = tables.open_file(filename, mode='r')
images = np.array(f.root.image)
servo = np.array(f.root.servo)
f.close()
print(len(images))
nr = 0
for i in range(len(images)):
image = images[i]
srv = servo[i]
if srv == 0:
continue
print(i)
if 1450 <= srv <= 1570:
image = cv2.arrowedLine(image, (25, 50), (25, 10), (255, 255, 0))
print('fwd\n')
elif srv < 1300:
image = cv2.arrowedLine(image, (10, 10), (50, 10), (255,255,0))
print('right\n')
elif srv > 1700:
image = cv2.arrowedLine(image, (50, 10), (10, 10), (255, 255, 0))
print('left\n')
nr += 1
# print(nr)
cv2.imshow('img', image)
time.sleep(0.5)
k = cv2.waitKey(5) & 0xFF
if k == 27:
stop = input()
if stop == 'y':
exit()
cv2.destroyAllWindows()