|
|
|
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[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) |
|
|
|
|
|
|