How to measure relative distance (Y axis) between two physical objects?

Hi,

I am currently developing an AR app that reacts to various positions of physical objects (lego-like bricks) that are placed on the desk in a real-time.


If I place the first block on the desk and second block so it is next to the first one, but in a different Y position, is it possible to compute a Y distance relative to the first object?


I would like the app to react to the changing position in real-time. AR would then change the color overlay and number displayed on that brick.

For better illustration, please see this GIF: https://imgur.com/a/RsciD


Would I need to use markers to identify the bricks? Is it possible with ARKit or do I need to use OpenCV?

All suggestions are more than welcome! 🙂


Thank you

Replies

This should be pretty straight forward if I understand you correctly.


you can get each nodes position, maybe just keep track of the last node clicked


var lastNode:SCNode? = nil

let currentNode:SCNode = placeNode()

currentNode.position = SCNVector3dMake(currentNode.position.x,lastNode.position.x+30,currentNode.position.z)

lastNode = currentNode

Would you please explain the code a little bit? I am working in unity and C# and my Swift knowledge is rather limited. Thank you very much for your help.