MCPcopy Create free account
hub / github.com/42dot/VFDepth / aug_depth_params

Function aug_depth_params

utils/visualize.py:9–57  ·  view source on GitHub ↗

This function augments camera parameters for depth synthesis.

(K, n_steps= 75)

Source from the content-addressed store, hash-verified

7
8
9def aug_depth_params(K, n_steps= 75):
10 """
11 This function augments camera parameters for depth synthesis.
12 """
13 # augmented parameters for visualization
14 aug_params = []
15
16 # roll augmentations
17 roll_aug = [i for i in range(0, n_steps + 1, 2)] + [i for i in range(n_steps, -n_steps - 1, -2)] + [i for i in range(-n_steps, 1, 2)]
18 ang_y, ang_z = 0.0, 0.0
19 for angle in roll_aug:
20 ang_x = _DEGTORAD * (angle / n_steps * 10.)
21 aug_params.append([torch.inverse(K), ang_x, ang_y, ang_z])
22
23 # pitch augmentations
24 pitch_aug = [i for i in range(0, 50 + 1, 2)] + [i for i in range(50, -50 - 1, -2)] + [i for i in range(-50, 1, 2)]
25 ang_x, ang_z = 0.0, 0.0
26 for angle in pitch_aug:
27 ang_y = _DEGTORAD * (angle / 10.)
28 aug_params.append([torch.inverse(K), ang_x, ang_y, ang_z])
29
30 # focal length augmentations
31 focal_ratio = K[:, 1, 0, 0] / K[:, 0, 0, 0]
32 focal_ratio_aug = focal_ratio / 1.5
33 ang_x, ang_y, ang_z = 0.0, 0.0, 0.0
34
35 for f_idx in range(100 + 1):
36 f_scale = (f_idx / 100. * focal_ratio_aug + (1 - f_idx / 100.))[:, None]
37 K_aug = K.clone()
38 K_aug[:, :, 0, 0] *= f_scale
39 K_aug[:, :, 1, 1] *= f_scale
40 aug_params.append([torch.inverse(K_aug), ang_x, ang_y, ang_z])
41
42 for f_idx in range(50 + 1):
43 f_scale = (f_idx / 50. * focal_ratio + (1 - f_idx / 50.) * focal_ratio_aug)[:, None]
44 K_aug = K.clone()
45 K_aug[:, :, 0, 0] *= f_scale
46 K_aug[:, :, 1, 1] *= f_scale
47 aug_params.append([torch.inverse(K_aug), ang_x, ang_y, ang_z])
48
49 # yaw augmentations
50 yaw_aug = [i for i in range(360)]
51 inv_K_aug = torch.inverse(K_aug)
52 ang_x, ang_y = 0.0, 0.0
53 for i in yaw_aug:
54 ratio_i = i / 360.
55 ang_z = _DEGTORAD * 360 * ratio_i
56 aug_params.append([inv_K_aug, ang_x, ang_y, ang_z])
57 return aug_params
58
59
60def colormap(vis, normalize=True, torch_transpose=True):

Callers 1

forwardMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected