From d9609081aa48eb09750be22b2081d8309272643c Mon Sep 17 00:00:00 2001 From: rUv Date: Sat, 22 Aug 2026 17:29:10 -0400 Subject: [PATCH] feat(ios): add RuView LiDAR frame protocol --- .../native/RuViewLiDAR/RuViewFrame.swift | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 integrations/iphone-lidar/native/RuViewLiDAR/RuViewFrame.swift diff --git a/integrations/iphone-lidar/native/RuViewLiDAR/RuViewFrame.swift b/integrations/iphone-lidar/native/RuViewLiDAR/RuViewFrame.swift new file mode 100644 index 00000000..8ccd2d53 --- /dev/null +++ b/integrations/iphone-lidar/native/RuViewLiDAR/RuViewFrame.swift @@ -0,0 +1,87 @@ +import Foundation +import simd + +struct RuViewLiDARFrame: Codable, Sendable { + struct Intrinsics: Codable, Sendable { + let fx: Float + let fy: Float + let cx: Float + let cy: Float + let imageWidth: Int + let imageHeight: Int + } + + struct Pose: Codable, Sendable { + let matrix: [Float] + } + + struct Depth: Codable, Sendable { + let width: Int + let height: Int + let meters: [Float] + let confidence: [UInt8] + } + + struct Provenance: Codable, Sendable { + let sensor: String + let source: String + let privacyClass: String + let sequence: UInt64 + let timestampNs: UInt64 + let schema: String + } + + let type: String + let intrinsics: Intrinsics + let pose: Pose + let depth: Depth + let provenance: Provenance + + init( + intrinsics: simd_float3x3, + imageResolution: CGSize, + cameraTransform: simd_float4x4, + depthWidth: Int, + depthHeight: Int, + depthMeters: [Float], + confidence: [UInt8], + sequence: UInt64, + timestamp: TimeInterval + ) { + self.type = "ruview.lidar.depth.v1" + self.intrinsics = Intrinsics( + fx: intrinsics.columns.0.x, + fy: intrinsics.columns.1.y, + cx: intrinsics.columns.2.x, + cy: intrinsics.columns.2.y, + imageWidth: Int(imageResolution.width), + imageHeight: Int(imageResolution.height) + ) + self.pose = Pose(matrix: cameraTransform.columnMajorArray) + self.depth = Depth( + width: depthWidth, + height: depthHeight, + meters: depthMeters, + confidence: confidence + ) + self.provenance = Provenance( + sensor: "apple-arkit-scene-depth", + source: "live", + privacyClass: "geometry-only", + sequence: sequence, + timestampNs: UInt64(max(0, timestamp) * 1_000_000_000), + schema: "ruview.lidar.depth.v1" + ) + } +} + +private extension simd_float4x4 { + var columnMajorArray: [Float] { + [ + columns.0.x, columns.0.y, columns.0.z, columns.0.w, + columns.1.x, columns.1.y, columns.1.z, columns.1.w, + columns.2.x, columns.2.y, columns.2.z, columns.2.w, + columns.3.x, columns.3.y, columns.3.z, columns.3.w + ] + } +}