Post

Replies

Boosts

Views

Activity

Reply to Is there any way to detect if the user's face leave outside the ARSCNView?
Well, here is my solution now: declare a variable to store the time last face updated private var lastFaceUpdateTime: TimeInterval? update the time when the face updated: func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) { guard let faceAnchor = anchors.first as? ARFaceAnchor else { return } lastFaceUpdateTime = session.currentFrame?.timestamp } check if the face exist func session(_ session: ARSession, didUpdate frame: ARFrame) { updateFaceDetectedState() } func updateFaceDetectedState() { guard let lastFaceUpdateTime = lastFaceUpdateTime else { return } DispatchQueue.main.async { let currentTime = CACurrentMediaTime() let timeSinceLastUpdate = currentTime - lastFaceUpdateTime if timeSinceLastUpdate < 0.5 { print("Face is inside the scene view") } else { print("Face is outside the scene view") } } }
Jun ’23