在Hololens中创建一个静态坐标系统

huangapple go评论105阅读模式
英文:

Create a static co-ordinate system in Hololens

问题

我正在开发一个Hololens应用程序,在其中我放置了四个图像目标,并识别第五个图像目标相对于这些标记的坐标。如何将图像目标的位置转换为一个新的坐标系统,在该坐标系统中,四个图像目标的位置分别是(-5,-5),(-5,5),(5,5)和(5,-5),并相应地计算第五个图像目标的位置。

在Hololens中是否有任何SDK或工具可以实现这个目标?实现这个目标的最佳方法是什么?

英文:

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?

答案1

得分: 0

作为之前提到的,实际上你只需要一个单独的图像目标作为共享参考来定义/同步你们两者移动的坐标空间。

例如,将其放置在你的桌角 -> 最初两者都会参考这个图像目标。

=> 你已经设置好了一个同步的坐标系统锚点,现在可以用来共享相对位置和旋转。

HoloLens会根据跟踪到的参考图像旋转和放置你的参考锚定对象。


对于这个最简单的设置,我会确保所有共享的内容都放置在你主要的WorldAnchor对象的子对象中。这个WorldAnchor你可以定位和旋转以匹配你用作参考的第一个跟踪到的图像目标。

现在你可以通过传输和重新应用你的物体的localPositionlocalRotationlocalScale来简单地与远程用户同步。由于在你和接收方的两端,物体都被放置在WorldAnchor下作为子对象,它们会自动相对于该锚点正确放置。因此,确保这一个锚点GameObject在两端都正确放置和定位就足以建立一个共享坐标空间。


如果不使用父子关系,你也可以通过WorldAnchorTransform组件进行操作,例如:

var positionToSend = worldAnchor.InverseTransformPoint(otherTargetWorldPosition);

然后在接收方相应地:

trackedObject.position = worldAnchor.TransformPoint(receivedRelativePosition);

同样,你也可以在旋转方面做相同的操作(参见What is the rotation equivalent of InverseTransformPoint?)。

英文:

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?

huangapple
  • 本文由 发表于 2023年5月17日 08:44:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76267901.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定