0 Replies
      Latest reply: Dec 14, 2017 5:02 AM by jishn RSS
      jishn Level 1 Level 1 (0 points)



        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?