MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / load_camera_data

Function load_camera_data

utils/readgt_colmap.py:15–50  ·  view source on GitHub ↗
(file_path)

Source from the content-addressed store, hash-verified

13 return R
14
15def load_camera_data(file_path):
16 with open(file_path, 'r') as file:
17 lines = file.readlines()
18
19 data = []
20 for line in lines:
21 if line.startswith("#") or not line.strip():
22 continue
23 parts = line.strip().split()
24
25 camera_id = int(parts[0]) # CAMERA_ID
26 model = parts[1] # MODEL
27 width = int(parts[2]) # WIDTH
28 height = int(parts[3]) # HEIGHT
29 params = list(map(float, parts[4:])) # PARAMS start from fifth
30 K = np.eye(3)
31 if model == "SIMPLE_PINHOLE":
32 # params = [f, cx, cy]
33 K[0, 0] = params[0] # f
34 K[1, 1] = params[0] # f
35 K[0, 2] = params[1] # cx
36 K[1, 2] = params[2] # cy
37 elif model == "PINHOLE":
38 # params = [fx, fy, cx, cy]
39 K[0, 0] = params[0] # fx
40 K[1, 1] = params[1] # fy
41 K[0, 2] = params[2] # cx
42 K[1, 2] = params[3] # cy
43 else:
44 raise ValueError(f"Unsupported camera model: {model}")
45 data.append((camera_id, K, width, height))
46
47 camera_df = pd.DataFrame(data, columns=['CAMERA_ID', 'K', 'width', 'height'])
48 camera_df.set_index('CAMERA_ID', inplace=True)
49
50 return camera_df
51
52def load_colmap_camera(gt_path):
53 camera_path = gt_path + "/sparse/cameras.txt"

Callers 2

load_colmap_cameraFunction · 0.85
load_colmap_gtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected