forked from geaxgx/depthai_blazepose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtil.py
61 lines (47 loc) · 1.24 KB
/
Util.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
import math
import gripper_fcn as gf
import time
def image2camera(resoltion, z, px, py):
fx = 1485.7717 * resoltion
fy = 1483.8920 * resoltion
cx = 968.5076 * resoltion
cy = 537.6301 * resoltion
# while True:
# z = float(input('Z: '))
# px = float(input('pixel x_coord: '))
# py = float(input('pixel y_coord: '))
x = ((px - cx) * z) / fx
y = ((py - cy) * z) / fy
print(x)
print(y)
def isInCell(x, y):
# (770, 590) (707, 345)
# y = 3.89x - 2404.44
if (y < 345 or y > 590):
return False
if (y < 3.89 * x - 2404.44 or x < 440):
return False
return True
# calculate distance between two numpy points
def get_distance(x, y):
a = x[0] - y[0]
b = x[1] - y[1]
c = x[2] - y[2]
return math.sqrt(a * a + b * b + c * c)
def open_gripper(grip):
#grip.resetActivate()
# grip.reset()
# grip.printInfo()
# grip.activate()
# grip.printInfo()
print("gripper opening ...................")
grip.goTo(0)
# time.sleep(2)
# grip.goTo(230)
# time.sleep(2)
def close_gripper(grip):
print("gripper closing ...................")
grip.goTo(205)
# get the system-wise time in sec
def now():
return time.perf_counter()