Skip to content

Commit add445b

Browse files
committed
add camera position visualization
1 parent 6363375 commit add445b

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_fitting_error(mesh, regressor, cam_params, joints, hand_type, capture_id
6161
print('Fix shapedirs bug of MANO')
6262
mano_layer['left'].shapedirs[:,0,:] *= -1
6363

64-
root_path = 'PATH_TO_DB'
64+
root_path = '../../data/InterHand2.6M/data/'
6565
img_root_path = osp.join(root_path, 'images')
6666
annot_root_path = osp.join(root_path, 'annotations')
6767
subset = 'all'
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import json
2+
import numpy as np
3+
from mpl_toolkits.mplot3d import Axes3D
4+
import matplotlib.pyplot as plt
5+
import matplotlib as mpl
6+
7+
# load camera positions
8+
campos_dict = {}
9+
for subset in ('all', 'machine_annot', 'human_annot'):
10+
for split in ('train', 'test', 'val'):
11+
12+
if split == 'val' and subset != 'machine_annot':
13+
continue
14+
15+
with open('../../data/InterHand2.6M/data/annotations/' + subset + '/InterHand2.6M_' + split + '_camera.json') as f:
16+
cameras = json.load(f)
17+
for capture_id in cameras.keys():
18+
for cam_id in cameras[capture_id]['campos'].keys():
19+
campos = np.array(cameras[capture_id]['campos'][cam_id], dtype=np.float32)
20+
21+
# exact camera positions can be slightly different for each 'capture_id'.
22+
# however, just overwrite them for the visualization purpose.
23+
if cam_id not in campos_dict:
24+
campos_dict[cam_id] = campos
25+
26+
# plot camera positions
27+
fig = plt.figure()
28+
ax = fig.add_subplot(111, projection='3d')
29+
30+
# Convert from plt 0-1 RGBA colors to 0-255 BGR colors for opencv.
31+
cmap = plt.get_cmap('rainbow')
32+
cam_num = len(campos_dict)
33+
colors = [cmap(i) for i in np.linspace(0, 1, cam_num)]
34+
colors = [np.array((c[2], c[1], c[0])) for c in colors]
35+
36+
for i, k in enumerate(campos_dict.keys()):
37+
ax.scatter(campos_dict[k][0], campos_dict[k][2], -campos_dict[k][1], c=colors[i], marker='o')
38+
ax.text(campos_dict[k][0], campos_dict[k][2], -campos_dict[k][1], k)
39+
40+
ax.set_xticklabels([])
41+
ax.set_yticklabels([])
42+
ax.set_zticklabels([])
43+
plt.show()
44+

0 commit comments

Comments
 (0)