0

I need to find the distance between two points inside a room using ARKit. I will explain my scenario. Inside a room I have one predefined point. Say that point is (x1,y1,z1). I grabbed this value from ARKit ARCamera.transform's current position. I dynamically moved to another point whose ARCamera.transform's current position is (x2,y2,z2). My intention is to find real world distance between the two.

func session(_ session: ARSession, didUpdate frame: ARFrame) {
    let currentFrame = frame.camera.transform
    let x = frame.camera.transform.columns.3.x
    let y = frame.camera.transform.columns.3.y
    let z = frame.camera.transform.columns.3.z
    print( "camera transform :\(x),\(y),\(z)")
}

Please find the above code which am using to get camera current poistion.

Now here is the problem. (x2,y2,z2) is diifferent on each time I test at the same physical point (Please note that my starting point is kept same, so ARKit session starts on the same point each time),so the distance varies largerly. In short I can't rely on ARKit to give my camera's current point in a usefull manner , ARCamera.transform's current position seems a random value which varies depends on some unknown facts. On googling I have seen that ARCamera.transform's current position gives the position of device camera. Can anybody point a solution or correct me if am wrong or please tell me what exactly is ARCamera.transform's current position or how can we use ARCamera.transform's current position in real world positioning?

jishnu bala
  • 665
  • 8
  • 17
  • 1
    Your real world and device coordinate systems are different. Device coordinate system is created for each session entirely. You can't rely the virtual points in your device. But you can use arkit to measure distance of two points etc. Relative positions on your device should be correct. – ibrahim Dec 14 '17 at 15:22
  • hi Ibrahim, can we get the distance of two points , where one point is taken on a different session(but having the same starting point as of first session) – jishnu bala Dec 18 '17 at 07:47
  • 1
    No you can't these two virtual worlds created for each session are different from each other. You can get distance between two points on the same session. – ibrahim Dec 18 '17 at 12:06

0 Answers0