MCPcopy Create free account
hub / github.com/XiaoBaiiiiii/colmap-pcd / read_cameras_binary

Function read_cameras_binary

scripts/python/read_write_model.py:127–153  ·  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

125
126
127def read_cameras_binary(path_to_model_file):
128 """
129 see: src/base/reconstruction.cc
130 void Reconstruction::WriteCamerasBinary(const std::string& path)
131 void Reconstruction::ReadCamerasBinary(const std::string& path)
132 """
133 cameras = {}
134 with open(path_to_model_file, "rb") as fid:
135 num_cameras = read_next_bytes(fid, 8, "Q")[0]
136 for _ in range(num_cameras):
137 camera_properties = read_next_bytes(
138 fid, num_bytes=24, format_char_sequence="iiQQ")
139 camera_id = camera_properties[0]
140 model_id = camera_properties[1]
141 model_name = CAMERA_MODEL_IDS[camera_properties[1]].model_name
142 width = camera_properties[2]
143 height = camera_properties[3]
144 num_params = CAMERA_MODEL_IDS[model_id].num_params
145 params = read_next_bytes(fid, num_bytes=8*num_params,
146 format_char_sequence="d"*num_params)
147 cameras[camera_id] = Camera(id=camera_id,
148 model=model_name,
149 width=width,
150 height=height,
151 params=np.array(params))
152 assert len(cameras) == num_cameras
153 return cameras
154
155
156def write_cameras_text(cameras, path):

Callers 1

read_modelFunction · 0.85

Calls 2

read_next_bytesFunction · 0.85
CameraClass · 0.50

Tested by

no test coverage detected