-
Notifications
You must be signed in to change notification settings - Fork 3
/
05-create-dashboard-images.py
executable file
·44 lines (33 loc) · 1.18 KB
/
05-create-dashboard-images.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
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
from dd_pose.dataset import Dataset
from dd_pose.dataset_item import DatasetItem
from dd_pose.visualization_helpers import get_dashboard
from dd_pose.jupyter_helpers import showimage
import cv2
from multiprocessing import Pool
d = Dataset()
subject, scenario, humanhash = sys.argv[1:4]
subject = int(subject)
scenario = int(scenario)
print("Subject: %02d" % subject)
print("Scenario: %02d" % scenario)
print("Humanhash: %s" % humanhash)
di_dict = d.get(subject, scenario, humanhash)
di = DatasetItem(di_dict)
print(di)
dashboard_images_dir = os.path.join(os.environ['DD_POSE_DATA_ROOT_DIR'], '02-dashboard-images', 'subject-%02d' % di.get_subject(), 'scenario-%02d' % di.get_scenario(), di.get_humanhash())
if not os.path.exists(dashboard_images_dir):
os.makedirs(dashboard_images_dir)
def create_and_write_dashboard(stamp):
print(stamp)
dashboard_image = get_dashboard(di, stamp)
cv2.imwrite(os.path.join(dashboard_images_dir, '%ld.png' % stamp), dashboard_image)
# create dashboards in parallel
p = Pool(8)
p.map(create_and_write_dashboard, di.get_stamps())
p.close()
p.join()
print("Done!")