MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / convertCameraModel

Function convertCameraModel

src/utils/cameraModelConversions.ts:64–87  ·  view source on GitHub ↗
(
  camera: Camera,
  targetModelId: CameraModelId,
  threshold: number = DEFAULT_CONVERSION_THRESHOLD
)

Source from the content-addressed store, hash-verified

62 * @returns Conversion result with new parameters or error
63 */
64export function convertCameraModel(
65 camera: Camera,
66 targetModelId: CameraModelId,
67 threshold: number = DEFAULT_CONVERSION_THRESHOLD
68): ConversionResult {
69 const { modelId: fromModel, params } = camera;
70
71 // Same model - no conversion needed
72 if (fromModel === targetModelId) {
73 return { type: 'exact', params: [...params] };
74 }
75
76 // Check compatibility first
77 const compatibility = canConvertModel(fromModel, targetModelId);
78 if (compatibility === 'incompatible') {
79 return {
80 type: 'incompatible',
81 reason: getIncompatibilityReason(fromModel, targetModelId),
82 };
83 }
84
85 // Perform the conversion
86 return performConversion(fromModel, targetModelId, params, threshold);
87}
88
89function getIncompatibilityReason(from: CameraModelId, to: CameraModelId): string {
90 const fromName = getModelName(from);

Callers 4

createConvertedCameraFunction · 0.85
getConversionPreviewFunction · 0.85

Calls 3

canConvertModelFunction · 0.85
getIncompatibilityReasonFunction · 0.85
performConversionFunction · 0.85

Tested by

no test coverage detected