问题描述
我正在尝试从 ARKit 会话的实时摄像头馈送中创建 2D 面部展开图像。
我看到there is another question about mapping an image onto a mesh。我的问题有所不同 - 它是关于从网格和相机馈送生成图像(或许多较小的图像)。
- 会话检测到用户的面部并添加一个
ARFaceAnchor
到 渲染器。 - 锚点有一个
geometry
对象,定义了一个网格 - 网格有大量的顶点
- 对于每次更新,都有一个对应的相机图像
- 相机图像有一个包含图像数据的像素缓冲区
如何检索面部锚点顶点周围的图像数据,以将面部从相应的相机帧“缝合”在一起?
var session: ARSession = self.sceneView.session
func renderer(_ renderer: SCNSceneRenderer,didUpdate node: SCNNode,for anchor: aranchor) {
if let faceAnchor = anchor as? ARFaceAnchor,let faceGeometry: ARSCNFaceGeometry = faceGeometry {
if let pixelBuffer: CVPixelBuffer = session.currentFrame?.capturedImage,let anchors: [aranchor] = session.currentFrame?.anchors {
print("how to get pixel buffer bytes around any given anchor?")
}
for index in 0 ..< faceGeometry.vertices.count {
let point = faceGeometry.vertices[index]
let position = SCNVector3(point.x,point.y,point.z)
print("How to use this position to retrieve image data from pixel buffer around this position?")
}
}
}
包括面几何顶点位置的示例
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)