gen_for_panorama.py 1.2 KB
Newer Older
Nianchen Deng's avatar
sync    
Nianchen Deng committed
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
import json
import numpy as np
from itertools import product


tbox = [0.1, 0.1, 0.1]

dataset_desc = {
    "gl_coord": True,
    'view_res': {
        'x': 1440,
        'y': 1600
    },
    'cam_params': {
        'fov': 110.0,
        'cx': 0.5,
        'cy': 0.5,
        'normalized': True
    },
    'range': {
        'min': [-tbox[0] / 2, -tbox[1] / 2, -tbox[2] / 2, 0, 0],
        'max': [tbox[0] / 2, tbox[1] / 2, tbox[2] / 2, 0, 0]
    },
    'samples': [3, 3, 3, 1, 1],
    'view_centers': [],
    'view_rots': []
}
panorama_pose_content = []
data_desc_file = f'for_panorama.json'
panorama_pose_file = "for_lipis.json"


ranges = [
    np.linspace(dataset_desc['range']['min'][i],
                dataset_desc['range']['max'][i],
                dataset_desc['samples'][i])
    for i in range(0, 3)
]

for x, y, z in product(*ranges):
    dataset_desc['view_centers'].append([x, y, z])
    dataset_desc['view_rots'].append([0, 0])
    panorama_pose_content.append({
        "rotation_euler": [0.0, 0.0, 0.0],
        "location": [x, y, z]
    })

with open(data_desc_file, 'w') as fp:
    json.dump(dataset_desc, fp, indent=4)

with open(panorama_pose_file, 'w') as fp:
    json.dump(panorama_pose_content, fp, indent=4)