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

Function parseRigsText

src/parsers/rigs.ts:99–196  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

97 * 0 3 1 0.7 0.0 0.7 0.0 -1.0 0.0 0.0
98 */
99export function parseRigsText(text: string): Map<number, Rig> {
100 const rigs = new Map<number, Rig>();
101 const lines = text.split('\n');
102
103 let i = 0;
104 while (i < lines.length) {
105 const line = lines[i].trim();
106 i++;
107
108 // Skip comments and empty lines
109 if (line.startsWith('#') || line === '') continue;
110
111 const parts = line.split(/\s+/);
112 if (parts.length < 4) continue;
113
114 // Parse rig header: RIG_ID, NUM_SENSORS, REF_SENSOR_TYPE, REF_SENSOR_ID
115 const rigId = parseColmapIntegerToken(parts[0], { min: 0 });
116 const numSensors = parseColmapIntegerToken(parts[1], { min: 0 });
117 const refSensorTypeValue = parseColmapIntegerToken(parts[2]);
118 const refSensorIdValue = parseColmapIntegerToken(parts[3], { min: 0 });
119
120 if (rigId === null || numSensors === null || refSensorTypeValue === null || refSensorIdValue === null) {
121 continue;
122 }
123
124 const refSensorType = parseSensorType(refSensorTypeValue, `text rig ${rigId} reference sensor`);
125 const refSensorId: SensorId = {
126 type: refSensorType,
127 id: refSensorIdValue,
128 };
129
130 const sensors: RigSensor[] = [];
131
132 // Add reference sensor with identity pose
133 sensors.push({
134 sensorId: refSensorId,
135 hasPose: false,
136 });
137
138 // Read additional sensors (num_sensors - 1 lines)
139 for (let j = 1; j < numSensors && i < lines.length; j++) {
140 const sensorLine = lines[i].trim();
141 i++;
142
143 if (sensorLine.startsWith('#') || sensorLine === '') {
144 j--; // Don't count this line
145 continue;
146 }
147
148 const sensorParts = sensorLine.split(/\s+/);
149 if (sensorParts.length < 3) continue;
150
151 const sensorTypeValue = parseColmapIntegerToken(sensorParts[0]);
152 const sensorId = parseColmapIntegerToken(sensorParts[1], { min: 0 });
153 const hasPoseValue = parseColmapIntegerToken(sensorParts[2], { min: 0 });
154
155 if (sensorTypeValue === null || sensorId === null || hasPoseValue === null) continue;
156

Callers 1

rigs.test.tsFile · 0.90

Calls 3

parseColmapIntegerTokenFunction · 0.90
parseSensorTypeFunction · 0.90
parseColmapNumberTokensFunction · 0.90

Tested by

no test coverage detected