MCPcopy
hub / github.com/zju3dv/4K4D / read_cameras_binary

Function read_cameras_binary

easyvolcap/utils/colmap_utils.py:159–185  ·  view source on GitHub ↗

see: src/base/reconstruction.cc void Reconstruction::WriteCamerasBinary(const std::string& path) void Reconstruction::ReadCamerasBinary(const std::string& path)

(path_to_model_file)

Source from the content-addressed store, hash-verified

157
158
159def read_cameras_binary(path_to_model_file):
160 """
161 see: src/base/reconstruction.cc
162 void Reconstruction::WriteCamerasBinary(const std::string& path)
163 void Reconstruction::ReadCamerasBinary(const std::string& path)
164 """
165 cameras = {}
166 with open(path_to_model_file, "rb") as fid:
167 num_cameras = read_next_bytes(fid, 8, "Q")[0]
168 for camera_line_index in range(num_cameras):
169 camera_properties = read_next_bytes(
170 fid, num_bytes=24, format_char_sequence="iiQQ")
171 camera_id = camera_properties[0]
172 model_id = camera_properties[1]
173 model_name = CAMERA_MODEL_IDS[camera_properties[1]].model_name
174 width = camera_properties[2]
175 height = camera_properties[3]
176 num_params = CAMERA_MODEL_IDS[model_id].num_params
177 params = read_next_bytes(fid, num_bytes=8 * num_params,
178 format_char_sequence="d" * num_params)
179 cameras[camera_id] = Camera(id=camera_id,
180 model=model_name,
181 width=width,
182 height=height,
183 params=np.array(params))
184 assert len(cameras) == num_cameras
185 return cameras
186
187
188def write_cameras_text(cameras, path):

Callers 4

mainFunction · 0.90
colmap_to_nerf.pyFile · 0.90
read_modelFunction · 0.85
correct_colmap_scaleFunction · 0.85

Calls 2

read_next_bytesFunction · 0.85
CameraClass · 0.70

Tested by

no test coverage detected