获取检测到的图像的方向并正确旋转图像

时间:2019-12-26 12:51:55

标签: swift arkit scnnode arimageanchor

我有一个小程序,可以检测已知图像并将其显示给用户。我使用ARImageTrackingConfiguration来检测图像。

    func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
        guard let imageAnchor = anchor as? ARImageAnchor else { return nil }
        status = .imageDetected

        let node = SCNNode()

        // Create Node
        let size = imageAnchor.referenceImage.physicalSize
        let plane = SCNPlane(width: size.width, height: size.height)
        let checkmarkImage = UIImage(systemName: "checkmark.rectangle")!.colored(.green)
        plane.firstMaterial?.diffuse.contents = checkmarkImage
        let planeNode = SCNNode(geometry: plane)
        planeNode.eulerAngles.x = -.pi / 2
        node.addChildNode(planeNode)

        return node
    }

检测到我的图像后,我想向用户展示它们(作品),但我也想获取图像的方向并将其旋转为正确的方向。我尝试了imageAnchor和节点,但没有任何效果。 我还添加了一张图片,可以更清楚地显示问题。

Image detected, arrow is in correct orientation but I don't know how to get the orientation of the detected image and show it correctly

0 个答案:

没有答案