import pickle import numpy as np def read_pickle(pkl_path): with open(pkl_path, 'rb') as f: u = pickle._Unpickler(f) u.encoding = 'latin1' return u.load() def get_camera(camera_path): camera = read_pickle(camera_path) K = np.zeros([3, 3]) K[0, 0] = camera['camera_f'][0] K[1, 1] = camera['camera_f'][1] K[:2, 2] = camera['camera_c'] K[2, 2] = 1 R = np.eye(3) T = np.zeros([3]) D = camera['camera_k'] camera = {'K': K, 'R': R, 'T': T, 'D': D} return camera