-
Notifications
You must be signed in to change notification settings - Fork 15
/
demo.py
71 lines (53 loc) · 2.4 KB
/
demo.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
import time
import smpl.numpy
import poseviz
import numpy as np
import cameralib
def main():
# Names of the body joints. Left joint names must start with 'l', right with 'r'.
joint_names = ['l_wrist', 'l_elbow']
# Joint index pairs specifying which ones should be connected with a line (i.e., the bones of
# the body, e.g. wrist-elbow, elbow-shoulder)
joint_edges = [[0, 1]]
viz = poseviz.PoseViz(joint_names, joint_edges)
# Iterate over the frames of e.g. a video
for i in range(1):
# Get the current frame
frame = np.zeros([720, 1280, 3], np.uint8)
# Make predictions here
# ...
# Update the visualization
viz.update(
frame=frame,
boxes=np.array([[10, 20, 100, 100]], np.float32),
poses=np.array([[[100, 100, 2000], [-100, 100, 2000]]], np.float32),
camera=cameralib.Camera.from_fov(55, frame.shape[:2]))
def main_smpl():
smpl_canonical = np.load('/work/sarandi/projects/localizerfields/canonical_vertices_smpl.npy') * 1000 + [0, 0, 3000]
# Names of the body joints. Left joint names must start with 'l', right with 'r'.
joint_names = ['l_wrist', 'l_elbow']
# Joint index pairs specifying which ones should be connected with a line (i.e., the bones of
# the body, e.g. wrist-elbow, elbow-shoulder)
joint_edges = [[0, 1]]
faces = smpl.numpy.get_cached_body_model('smpl', 'neutral').faces
with poseviz.PoseViz(joint_names, joint_edges, body_model_faces=faces) as viz:
# Iterate over the frames of e.g. a video
for i in range(1):
# Get the current frame
frame = np.zeros([720, 1280, 3], np.uint8)
# Make predictions here
# ...
# Update the visualization
viz.update(
frame=frame,
boxes=np.array([[10, 20, 100, 100]], np.float32),
vertices=np.array([smpl_canonical+[500,0,5000]]),
camera=cameralib.Camera.from_fov(55, frame.shape[:2], world_up=(0,1,0)))
viz.update(
frame=frame,
boxes=np.array([[10, 20, 100, 100]], np.float32),
vertices=np.array([smpl_canonical+[-500,0,3000], smpl_canonical+[-500,0,5000]]),
camera=cameralib.Camera.from_fov(55, frame.shape[:2], world_up=(0,1,0)))
time.sleep(1000)
if __name__ == '__main__':
main_smpl()