(buffer: ArrayBuffer)
| 21 | * - double[]: params (variable count based on model) |
| 22 | */ |
| 23 | export function parseCamerasBinary(buffer: ArrayBuffer): Map<number, Camera> { |
| 24 | const reader = new BinaryReader(buffer); |
| 25 | const cameras = new Map<number, Camera>(); |
| 26 | |
| 27 | const numCameras = reader.readUint64AsNumber(); |
| 28 | |
| 29 | for (let i = 0; i < numCameras; i++) { |
| 30 | const cameraId = reader.readUint32(); |
| 31 | const modelId = parseCameraModelId(reader.readInt32(), `binary camera ${cameraId}`); |
| 32 | const width = reader.readUint64AsNumber(); |
| 33 | const height = reader.readUint64AsNumber(); |
| 34 | |
| 35 | // Get number of parameters for this camera model |
| 36 | const numParams = getCameraModelNumParams(modelId); |
| 37 | const params: number[] = []; |
| 38 | for (let j = 0; j < numParams; j++) { |
| 39 | params.push(reader.readFloat64()); |
| 40 | } |
| 41 | |
| 42 | cameras.set(cameraId, { |
| 43 | cameraId, |
| 44 | modelId, |
| 45 | width, |
| 46 | height, |
| 47 | params, |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | return cameras; |
| 52 | } |
| 53 | |
| 54 | /** A camera record skipped by {@link parseCamerasText} because its model is unknown. */ |
| 55 | export interface SkippedCameraRecord { |
no test coverage detected