MCPcopy Create free account
hub / github.com/SpectacularAI/sdk / convert_distortion

Function convert_distortion

python/cli/process/process.py:209–235  ·  view source on GitHub ↗
(cam)

Source from the content-addressed store, hash-verified

207 f.write(' '.join([str(v) for v in r]) + '\n')
208
209def convert_distortion(cam):
210 coeffs = cam.get('distortionCoefficients', None)
211 if coeffs is None:
212 return None
213
214 if all([c == 0.0 for c in coeffs]): return None
215
216 get_coeffs = lambda names: dict(zip(names.split(), coeffs))
217
218 model = 'OPENCV'
219 if cam['model'] == 'brown-conrady':
220 r = get_coeffs('k1 k2 p1 p2 k3 k4 k5 k6')
221 elif cam['model'] == 'pinhole':
222 r = get_coeffs('k1 k2 k3')
223 r['p1'] = 0
224 r['p2'] = 0
225 elif cam['model'] == 'kannala-brandt4':
226 model = 'OPENCV_FISHEYE'
227 r = get_coeffs('k1 k2 k3 k4')
228 else:
229 raise RuntimeError(f"unsupported camera model: {cam['model']}")
230 r['model'] = model
231 r['cx'] = cam['principalPointX']
232 r['cy'] = cam['principalPointY']
233 r['fx'] = cam['focalLengthX']
234 r['fy'] = cam['focalLengthY']
235 return r
236
237def convert_json_taichi_to_nerfstudio(d):
238 import numpy as np

Callers 1

processFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected