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

Function parseFramesText

src/parsers/frames.ts:85–164  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

83 * 0 3 3
84 */
85export function parseFramesText(text: string): Map<number, Frame> {
86 const frames = new Map<number, Frame>();
87 const lines = text.split('\n');
88
89 let i = 0;
90 while (i < lines.length) {
91 const line = lines[i].trim();
92 i++;
93
94 // Skip comments and empty lines
95 if (line.startsWith('#') || line === '') continue;
96
97 const parts = line.split(/\s+/);
98 if (parts.length < 10) continue;
99
100 // Parse frame header: FRAME_ID, RIG_ID, QW, QX, QY, QZ, TX, TY, TZ, NUM_DATA_IDS
101 const frameId = parseColmapIntegerToken(parts[0], { min: 0 });
102 const rigId = parseColmapIntegerToken(parts[1], { min: 0 });
103 const qvecValues = parseColmapNumberTokens(parts.slice(2, 6));
104 const tvecValues = parseColmapNumberTokens(parts.slice(6, 9));
105 const numDataIds = parseColmapIntegerToken(parts[9], { min: 0 });
106
107 if (frameId === null || rigId === null || qvecValues === null || tvecValues === null || numDataIds === null) {
108 continue;
109 }
110
111 const rigFromWorld = {
112 qvec: [
113 qvecValues[0],
114 qvecValues[1],
115 qvecValues[2],
116 qvecValues[3],
117 ] as [number, number, number, number],
118 tvec: [
119 tvecValues[0],
120 tvecValues[1],
121 tvecValues[2],
122 ] as [number, number, number],
123 };
124
125 const dataIds: FrameDataMapping[] = [];
126
127 // Read data ID mappings
128 for (let j = 0; j < numDataIds && i < lines.length; j++) {
129 const dataLine = lines[i].trim();
130 i++;
131
132 if (dataLine.startsWith('#') || dataLine === '') {
133 j--; // Don't count this line
134 continue;
135 }
136
137 const dataParts = dataLine.split(/\s+/);
138 if (dataParts.length < 3) continue;
139
140 const sensorType = parseColmapIntegerToken(dataParts[0]);
141 const sensorId = parseColmapIntegerToken(dataParts[1], { min: 0 });
142 const dataId = parseColmapIntegerToken(dataParts[2], { min: 0 });

Callers 1

frames.test.tsFile · 0.90

Calls 3

parseColmapIntegerTokenFunction · 0.90
parseColmapNumberTokensFunction · 0.90
parseSensorTypeFunction · 0.90

Tested by

no test coverage detected