-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.py
92 lines (71 loc) · 1.92 KB
/
run.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
import os
import time
import serial
import warnings
import numpy as np
import csv
port = ''
#s = serial.Serial(port,9600)
os.system('python3 -W ignore demo_cpm_hand.py --DEMO_TYPE test_imgs/hand.jpg')
v=[]
with open('test_file.csv') as file:
reader = csv.reader(file, delimiter=',')
for row in reader:
v.append(row[0])
v.append(row[1])
'''
f=open("testfile.txt","r")
v=f.readline()
print('running...')
v = v.strip().split(' ')
'''
ratio_n = []
x1 = (float(v[0])+float(v[2])+float(v[6])+float(v[10])+float(v[14]))/5
y1 = (float(v[1])+float(v[3])+float(v[7])+float(v[11])+float(v[15]))/5
for i in range(4):
x2 = float(v[4*i+2])
y2 = float(v[4*i+3])
x3 = float(v[4*i+4])
y3 = float(v[4*i+5])
fullen1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
fullen2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
ratio_n.append(fullen2)
#ratio_n.append(fullen2/fullen1)
#f.close()
print(ratio_n)
'''
f=open("testfile.txt","w")
for x in ratio_n:
f.write(str(x)+' ')
f.close()
os.system('python3 -W ignore demo_cpm_hand.py --DEMO_TYPE SINGLE')
'''
with open('test_file.csv', mode='w') as file:
writer = csv.writer(file, delimiter=',')
writer.writerow(ratio_n)
os.system('python3 -W ignore demo_cpm_hand.py --DEMO_TYPE SINGLE')
'''
for i in ['second','third','fourth','fifth']:
ratio = []
os.system('python3 -W ignore demo_cpm_hand.py --DEMO_TYPE test_imgs/'+i+'.jpg')
f=open("testfile.txt","r")
v=f.readline()
v = v.strip().split(' ')
x1 = float(v[0])
y1 = float(v[1])
for j in range(4):
x2 = float(v[4*j+2])
y2 = float(v[4*j+3])
x3 = float(v[4*j+4])
y3 = float(v[4*j+5])
length1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
length2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
ratio.append(length2/length1)
ratio = np.divide(np.array(ratio),np.array(ratio_n))
ratio=ratio*(ratio<1)+(ratio>=1)
ratio=ratio*(ratio>-1)-(ratio<=-1)
deg = np.degrees(np.arccos(ratio))
print(deg)
#s.write(str(deg).encode())
f.close()
'''