SCNNode未显示在ARFrame的captureImage中 [英] SCNNode not showing in ARFrame's capturedImage

查看:150
本文介绍了SCNNode未显示在ARFrame的captureImage中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将SCNNode添加到ARSCNView:

I added a SCNNode to a ARSCNView:

 func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
  guard let faceAnchor = anchor as? ARFaceAnchor else { return nil }
  guard let device = sceneView.device else { return nil }
  guard let faceGeometry = ARSCNFaceGeometry(device: device, fillMesh: true) else { return nil }

  let faceNode = FaceNode(faceGeometry)

  // Node is a custom SCNNode class
  let glassesNode = Node(image: UIImage(named: "glasses")!, position: .glasses, anchor: faceAnchor)
  faceNode.addChildNode(glassesNode)

  return faceNode
 }

然后,我使用此委托函数为每个框架添加一个过滤器.问题是添加了SCNNode:在frame.capturedImage中无法识别glassesNode.因此,没有将过滤器应用于SCNNode,而是应用于其他所有对象.

Then I use this delegate function to add a filter to each frame. The problem is the SCNNode that's added: glassesNode is not recognized in frame.capturedImage. Therefore, no filter is applied to the SCNNode, but is applied to everything else.

 func session(_ session: ARSession, didUpdate frame: ARFrame) {

  guard let image = CIImage(cvImageBuffer: frame.capturedImage)) else { return }

  let filterImage = setFilter(image)

  sceneView.scene.background.contents = context.createCGImage(filterImage, from: filterImage.extent)
 }

唯一的解决方法是使用ARSCNView的snapshot()属性.哪个效果很好. SCNNode已被过滤,但是屏幕上的UI元素存在太多延迟,这是一个问题.

The only workaround is to use the snapshot() property of ARSCNView. Which works well. The SCNNode gets filtered, but there is too much latency with UI elements on the screen which is a problem.

反正我可以使用ARFrame的capturedImage并让它识别ARSCNView上的SCNNode吗?

Is there anyway I can use ARFrame's capturedImage and have it recognize the SCNNode that is on the ARSCNView?

推荐答案

使用ARFrame的capturedImage是不可能的. ARKit本身并不知道您正在使用SceneKit渲染3D内容,因此capturedImage仅包含相机图像本身.

This is not possible using capturedImage of the ARFrame. ARKit itself is not aware that you are using SceneKit for rendering your 3D content, so the capturedImage will only contain the camera image itself.

这篇关于SCNNode未显示在ARFrame的captureImage中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆