MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / parseRigsBinary

Function parseRigsBinary

src/parsers/rigs.ts:23–86  ·  view source on GitHub ↗
(buffer: ArrayBuffer)

Source from the content-addressed store, hash-verified

21 * - if has_pose: double[7] (qw, qx, qy, qz, tx, ty, tz)
22 */
23export function parseRigsBinary(buffer: ArrayBuffer): Map<number, Rig> {
24 const reader = new BinaryReader(buffer);
25 const rigs = new Map<number, Rig>();
26
27 const numRigs = reader.readUint64AsNumber();
28
29 for (let i = 0; i < numRigs; i++) {
30 const rigId = reader.readUint32();
31 const numSensors = reader.readUint32();
32
33 const sensors: RigSensor[] = [];
34 let refSensorId: SensorId | null = null;
35
36 if (numSensors > 0) {
37 // Read reference sensor (first sensor, always has identity pose)
38 const refType = parseSensorType(reader.readInt32(), `binary rig ${rigId} reference sensor`);
39 const refId = reader.readUint32();
40 refSensorId = { type: refType, id: refId };
41
42 sensors.push({
43 sensorId: refSensorId,
44 hasPose: false, // Reference sensor has identity pose (implicit)
45 });
46
47 // Read additional sensors
48 for (let j = 1; j < numSensors; j++) {
49 const sensorType = parseSensorType(reader.readInt32(), `binary rig ${rigId} sensor ${j}`);
50 const sensorId = reader.readUint32();
51 const hasPose = reader.readUint8() !== 0;
52
53 const sensor: RigSensor = {
54 sensorId: { type: sensorType, id: sensorId },
55 hasPose,
56 };
57
58 if (hasPose) {
59 // Read sensor_from_rig pose: qw, qx, qy, qz, tx, ty, tz
60 const qw = reader.readFloat64();
61 const qx = reader.readFloat64();
62 const qy = reader.readFloat64();
63 const qz = reader.readFloat64();
64 const tx = reader.readFloat64();
65 const ty = reader.readFloat64();
66 const tz = reader.readFloat64();
67
68 sensor.pose = {
69 qvec: [qw, qx, qy, qz],
70 tvec: [tx, ty, tz],
71 };
72 }
73
74 sensors.push(sensor);
75 }
76 }
77
78 rigs.set(rigId, {
79 rigId,
80 refSensorId,

Callers 2

rigs.test.tsFile · 0.90

Calls 6

readUint64AsNumberMethod · 0.95
readUint32Method · 0.95
readInt32Method · 0.95
readUint8Method · 0.95
readFloat64Method · 0.95
parseSensorTypeFunction · 0.90

Tested by

no test coverage detected