(file_path)
| 13 | return R |
| 14 | |
| 15 | def 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 | |
| 52 | def load_colmap_camera(gt_path): |
| 53 | camera_path = gt_path + "/sparse/cameras.txt" |
no outgoing calls
no test coverage detected