File size: 1,237 Bytes
0780cd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
import numpy as np
import sys
import glob
import os
import json
import imageio
from tqdm import trange

arr = ['04-09_19_30_IMG_1192']*3

intrs = [np.loadtxt(os.path.join('./train/intrinsics', f+'.txt')) for f in arr]
poses = [np.loadtxt(os.path.join('./train/pose', f+'.txt')) for f in arr]

base = './static_path1'
os.makedirs(os.path.join(base, 'intrinsics'), exist_ok=True)
os.makedirs(os.path.join(base, 'pose'), exist_ok=True)

H, W = imageio.imread(os.path.join('./train/rgb', arr[0]+'.JPG')).shape[:2]

N = 100
obj = dict()
for i in range(N):
    idxa = i*(len(intrs)-1)//N
    idxb = idxa+1

    blendratio = (i-idxa*N//(len(intrs)-1))/(N//(len(intrs)-1))
    # intr = intrs[idxa]*(1-blendratio)+intrs[idxb]*blendratio
    intr = intrs[0]
    pose = poses[idxa]*(1-blendratio)+poses[idxb]*blendratio

    print(i, idxa, idxb, blendratio)

    fn = f'{i:06d}'
    np.savetxt(os.path.join(base, 'intrinsics', fn+'.txt'), intr.reshape(1, -1))
    np.savetxt(os.path.join(base, 'pose', fn+'.txt'), pose.reshape(1, -1))
    obj[fn+'.png'] = {'K': list(intr.reshape(-1)), 'W2C': list(pose.reshape(-1)), 'img_size': [W, H]}

with open(os.path.join(base, 'cam_dict_norm.json'), 'w') as f:
    json.dump(obj, f)