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

Function writePoints3DText

src/parsers/colmapTextWriters.ts:88–123  ·  view source on GitHub ↗
(points3D: Map<Point3DId, Point3D>)

Source from the content-addressed store, hash-verified

86}
87
88export function writePoints3DText(points3D: Map<Point3DId, Point3D>): string {
89 const lines: string[] = [];
90
91 let totalTrackLen = 0;
92 for (const pt of points3D.values()) {
93 totalTrackLen += pt.track.length;
94 }
95 const meanTrackLen = points3D.size > 0 ? (totalTrackLen / points3D.size).toFixed(6) : '0';
96
97 lines.push('# 3D point list with one line of data per point:');
98 lines.push('# POINT3D_ID, X, Y, Z, R, G, B, ERROR, TRACK[] as (IMAGE_ID, POINT2D_IDX)');
99 lines.push(`# Number of points: ${points3D.size}, mean track length: ${meanTrackLen}`);
100
101 for (const point3DId of sortedKeys(points3D)) {
102 const pt = points3D.get(point3DId)!;
103 const [x, y, z] = pt.xyz;
104 const [r, g, b] = pt.rgb;
105 const trackStr = pt.track.map((t) => `${t.imageId} ${t.point2DIdx}`).join(' ');
106
107 lines.push(
108 [
109 point3DId.toString(),
110 formatDouble(x),
111 formatDouble(y),
112 formatDouble(z),
113 r,
114 g,
115 b,
116 formatDouble(pt.error),
117 trackStr,
118 ].join(' ')
119 );
120 }
121
122 return lines.join('\n') + '\n';
123}
124
125export function writeRigsText(rigs: Map<RigId, Rig>): string {
126 const lines: string[] = [];

Calls 4

sortedKeysFunction · 0.90
formatDoubleFunction · 0.90
getMethod · 0.80
valuesMethod · 0.65

Tested by

no test coverage detected