Reputation: 176
I want to calculate the distance between any marker image saved in the iOS project which is used for detecting in Augmented Reality and your current position i.e. camera position using ARKIT ?
Upvotes: 1
Views: 1292
Reputation: 161
If you're using SceneKit and have the SCNNode*
that came with
-(void) renderer:(id<SCNSceneRenderer>)renderer didAddNode:(SCNNode *)node forAnchor:(ARAnchor*)anchor
then
[node convertPosition:{0,0,0} toNode:self.sceneView.pointOfView].z
is distance to camera.
Upvotes: 0
Reputation: 126177
As Apple’s documentation and sample code note:
ARImageAnchor
object.ARImageAnchor
is a subclass of ARAnchor
.ARAnchor
has a transform
property, which indicates its position and orientation in 3D space.ARCamera
on every frame (or you can get it from the session’s currentFrame
).ARCamera
also has a transform
property, indicating the camera’s position and orientation in 3D space.That should be enough for you to connect the dots...
Upvotes: 6