MCPcopy Create free account
hub / github.com/ai4ce/RAP / read_cameras_binary

Function read_cameras_binary

utils/read_write_model.py:136–168  ·  view source on GitHub ↗

see: src/colmap/scene/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

134
135
136def read_cameras_binary(path_to_model_file):
137 """
138 see: src/colmap/scene/reconstruction.cc
139 void Reconstruction::WriteCamerasBinary(const std::string& path)
140 void Reconstruction::ReadCamerasBinary(const std::string& path)
141 """
142 cameras = {}
143 with open(path_to_model_file, "rb") as fid:
144 num_cameras = read_next_bytes(fid, 8, "Q")[0]
145 for _ in range(num_cameras):
146 camera_properties = read_next_bytes(
147 fid, num_bytes=24, format_char_sequence="iiQQ"
148 )
149 camera_id = camera_properties[0]
150 model_id = camera_properties[1]
151 model_name = CAMERA_MODEL_IDS[camera_properties[1]].model_name
152 width = camera_properties[2]
153 height = camera_properties[3]
154 num_params = CAMERA_MODEL_IDS[model_id].num_params
155 params = read_next_bytes(
156 fid,
157 num_bytes=8 * num_params,
158 format_char_sequence="d" * num_params,
159 )
160 cameras[camera_id] = Camera(
161 id=camera_id,
162 model=model_name,
163 width=width,
164 height=height,
165 params=np.array(params),
166 )
167 assert len(cameras) == num_cameras
168 return cameras
169
170
171def write_cameras_text(cameras, path):

Callers 1

read_modelFunction · 0.85

Calls 2

CameraClass · 0.85
read_next_bytesFunction · 0.70

Tested by

no test coverage detected