如何解决如何使用 IPad 从 IPad 上的查看图像获取点云带有 RGB、设备上的 2D 坐标、3D 点坐标?
我指的是 ARKit 的示例代码“使用场景深度可视化点云”。
粒子缓冲区由RGB、3D坐标组成。我不知道设备上显示的点的索引。因此,我使用由 RGB、3D 坐标 (x,y,z) 组成的层扩展提取了点云。
但是,我只想提取在设备(IPad)上可见的具有 2D 坐标的点云。
我知道,Metal 着色器函数可以转换网格数据以查看数据。但是,我不知道这些信息存储在哪里。
我想知道如何在现实世界中保存和提取 RGB、激光雷达生成的 3D 坐标、设备上的 2D 坐标。
'''我的代码'''
func savePointsToFile() {
guard !self.isSavingFile else { return }
self.isSavingFile = true
// 1
var fileToWrite = ""
let headers = ["ply","format ascii 1.0","element vertex \(currentPointCount)","property float x","property float y","property float z","property uchar red","property uchar green","property uchar blue","property float cx","property float cy","property float depth","property uchar alpha","element face 0","property list uchar int vertex_indices","end_header"]
for header in headers {
fileToWrite += header
fileToWrite += "\r\n"
}
// 2
for i in 0..<currentPointCount {
// 3
let point = particlesBuffer[i]
let colors = point.color
// 4
let red = colors.x * 255.0
let green = colors.y * 255.0
let blue = colors.z * 255.0
// 5
let pvValue = "\(point.position.x) \(point.position.y) \(point.position.z) \(Int(red)) \(Int(green)) \(Int(blue)) \(point.texCoord.x) \(point.texCoord.y) \(point.depth) 255"
fileToWrite += pvValue
fileToWrite += "\r\n"
}
// 6
let paths = FileManager.default.urls(for: .documentDirectory,in: .userDomainMask)
let documentsDirectory = paths[0]
let file = documentsDirectory.appendingPathComponent("ply_\(UUID().uuidString).ply")
do {
// 7
try fileToWrite.write(to: file,atomically: true,encoding: String.Encoding.ascii)
self.isSavingFile = false
} catch {
print("Failed to write PLY file",error)
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。