gpt4 book ai didi

ios - ARKit 1.5 : Extract the recognized image

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:02:36 27 4
gpt4 key购买 nike

所以,我的目标是:

  • 找到已知图像
  • 从 sceneView 中提取它(例如拍摄快照)
  • 执行进一步处理

使用 ARReferenceImage 很容易完成第一步:

guard let referenceImages = ARReferenceImage.referenceImages(inGroupNamed: "AR Resources", bundle: nil) else { return }

let configuration = ARWorldTrackingConfiguration()

configuration.detectionImages = referenceImages

但现在我不知道如何从 SceneView 中提取图像。我将平面节点添加到 imageAnchor:

    func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
DispatchQueue.main.async { [unowned self] in
guard let imageAnchor = anchor as? ARImageAnchor
else { return }

let planeNode = self.getPlaneNode(withReferenceImage: imageAnchor.referenceImage)
planeNode.opacity = 0.5
planeNode.eulerAngles.x = -.pi / 2
node.addChildNode(planeNode)
}
}

结果: enter image description here

因此,我需要平面节点在屏幕上的投影来获取节点的二维屏幕坐标,然后切割图像。我找到了这个方法:renderer.projectPoint(node.position) 但它对我没有帮助。当整张图片都显示在屏幕上时,它甚至可以返回负值。

我的做法是否正确?任何帮助将不胜感激.

最佳答案

就我而言,我解决了它。

    let transform = node.simdConvertTransform(node.simdTransform, to: node.parent!)

let x = transform.columns.3.x
let y = transform.columns.3.y
let z = transform.columns.3.z

let position = SCNVector3(x, y, z)
let projection = renderer.projectPoint(position)

let screenPoint = CGPoint(x: CGFloat(projection.x), y: CGFloat( projection.y))

更多信息

ARKit 2 - Crop Recognizing Images

iOS 8 Core Image saving a section of an Image via Swift

https://nacho4d-nacho4d.blogspot.com/2012/03/coreimage-and-uikit-coordinates.html

关于ios - ARKit 1.5 : Extract the recognized image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50871959/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com