I am developing an application for Hololens where I place four image targets and identify the coordinates of the fifth image target relative to those markers. How to transform the image targets' position into a new coordinate system where the 4 image targets are (-5,-5),(-5,5),(5,5), and (5,-5) and calculate the position of the 5th image target accordingly.
Are there any sdks or tools for doing that in Hololens? What is the best method to achieve this?
As mentioned before, you actually only need one single image target as a shared reference to define/sync the coordinate space you both are moving in.
E.g. place it on the corner of your table(s) -> initially both reference this image target once.
=> You are all set up with a synchronized coordinate system anchor your can now use in order to share relative positions and rotations
HoloLens already will rotate and place your reference anchor object according to the tracked reference image.
Simplest setup I'd use for this is simply making sure all shared content is placed s a child of your main WorldAnchor
object. This WorldAnchor
you position and rotate to match with the first tracked image target you use as reference.
Now you can simply synchronize with remote users by transferring and reapplying your objects localPosition
, localRotation
, localScale
. Since on both your and the receiver side the objects are placed as child under the WorldAnchor
they are automatically placed correctly relative to that anchor. So ensuring that this one anchor GameObject
is placed and oriented correctly on both sides is already enough to build up a shared coordinate space.
Without using parenting you can also go through the Transform
component of the WorldAcnhor
and use e.g.
var positionToSend = worldAcnhor.InverseTransformPoint(otherTargetWorldPosition);
and on the receiver accordingly
trackedObject.position = worldAcnhor.TransformPoint(receivedRelativePosition);
Same you can do also with the rotation (see What is the rotation equivalent of InverseTransformPoint?