Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARKIT 2.0 Image Detection : can't find when image disappear with ARImageTrackingConfiguration

In the new arkit 2.0 documentation, it explain: and can accurately track when images disappear from view (or reappear afterward)

How could I be notified that the image is no loger visible ? I could not find the documentation about it.

Thankfully, Kevin

like image 918
Kevin Vacquier Avatar asked Nov 16 '25 18:11

Kevin Vacquier


1 Answers

An ARImageAnchor conforms to the ARTrackable Protocol which:

is adopted by ARKit classes, such as the ARFaceAnchor class, that represent moving objects in a scene.

ARSCNView and ARSKView automatically hide the nodes for anchors whose isTracked property is false.

You can read more about it here.

As such you can do something like this to check if your image is visible or not:

//--------------------------
//MARK: -  ARSessionDelegate
//--------------------------

extension ViewController: ARSessionDelegate{

    func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {

        //1. Enumerate Our Anchors To See If We Have Found Our Target Anchor
        for anchor in anchors{

            if let imageAnchor = anchor as? ARImageAnchor, imageAnchor == targetAnchor{

                //2. If The ImageAnchor Is No Longer Tracked Then Handle The Event
                if !imageAnchor.isTracked{

                }else{


                }
            }
        }
     }
}

Whereby targetAnchor is simply an ARImageAnchor I have stored reference to as a Global Variable.

Hope it helps...

like image 178
BlackMirrorz Avatar answered Nov 19 '25 10:11

BlackMirrorz