Nouman Ch
Nouman Ch

Reputation: 4121

How to get the latest Detected Plane in ARCore?

What I'm trying to achieve is to place model in front of the user without tapping on the plane. For that, I'm trying to get the latest Plane from the onUpdate method and then plane.centerPose out of it.

val plane = frame.getUpdatedTrackables(Point::class.java).last();
universalAnchorNode = AnchorNode(arFragment?.arSceneView?.session?.createAnchor(plane.centerPose))

What Issue I'm facing is, most of the time It still gives me a previous Plane instead of giving me an updated pose.

What I want is to get updated pose in onUpdate method.

Upvotes: 0

Views: 837

Answers (1)

neudroidEnt
neudroidEnt

Reputation: 11

Get the current frame.

arSceneView.scene.addOnUpdateListener {
    frame = arSceneView.arFrame ?: return@addOnUpdateListener
}

Then you can extract the plane

val plane = frame.getUpdatedTrackables(Plane::class.java)

Upvotes: 1

Related Questions