I am developing a ARKit ImageTracking app, for our AR experience we want Tracking image should be visible fully, If it is visible partially i need to show a UI message "Please make sure Marker is visible fully ". So i added a plane as SCNNode which is equal to marker size. as below and got bounding box or four corners of plane, but How to detect this Plane is fully visible , or All four corners of plane are in camera frame?

func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
    //1. If Out Target Image Has Been Detected Than Get The Corresponding Anchor
    guard let currentImageAnchor = anchor as? ARImageAnchor else { return }

    let x = currentImageAnchor.transform
    print(x.columns.3.x, x.columns.3.y , x.columns.3.z)

    //2. Get The Targets Name
    let name = currentImageAnchor.referenceImage.name!

    //3. Get The Targets Width & Height In Meters
    let width = currentImageAnchor.referenceImage.physicalSize.width
    let height = currentImageAnchor.referenceImage.physicalSize.height

    //4. Create A Plane Geometry To Cover The ARImageAnchor
    let planeNode = SCNNode()
    planeNode.name = "markerSizePlane"
    let planeGeometry = SCNPlane(width: width, height: height)
    planeGeometry.firstMaterial?.diffuse.contents = UIColor.blue
    planeNode.opacity = 0.25
    planeNode.geometry = planeGeometry

    //5. Rotate The PlaneNode To Horizontal
    planeNode.eulerAngles.x = -.pi/2

    //The Node Is Centered In The Anchor (0,0,0)

/* Getting corners of plane */
func renderer(_ renderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: TimeInterval) {
    var bottomLeft: SCNVector3!
    var topRight: SCNVector3!
    var topLeft: SCNVector3!
    var bottomRight: SCNVector3!

    //1. Get The Current Point Of View
    guard let pointOfView = sceneView.pointOfView else { return }

        node, stop in
            if node.name == "markerSizePlane"{
                //print("markerSizePlane position \(node.position)")
                let (min, max) = node.boundingBox
                bottomLeft = SCNVector3(min.x, min.y, 0)
                topRight = SCNVector3(max.x, max.y, 0)
                topLeft = SCNVector3(min.x, max.y, 0)
                bottomRight = SCNVector3(max.x, min.y, 0)


0 Answers