ARCore – 如何在没有任何特征点的情况下在墙壁等表面上放置/创建对象? [英] ARCore – How to place/create objects on surfaces like walls without any Feature Points?
问题描述
例如:我有兴趣在垂直平面上放置 2D 图像(例如:没有特征点的白色或单色墙).
For example: I am interested in placing 2D images on a vertical plane (like: white or single solid color walls with no feature points present).
有哪些不同的解决方法?
What are different workarounds?
我知道 ARCore 支持相对于其他对象放置对象.如何扩展它以满足我将对象相对于未检测到特征点的其他对象放置的要求?
I am aware that ARCore supports placement of objects with respect to other objects. How can I extend this to fulfill my requirement of placing objects relative to other objects where feature points are not detected?
非常感谢任何想法或解决方法.
Any ideas or workaround much appreciated.
推荐答案
您可以设置相对于摄像机位置的锚点 - 即,将摄像机指向要附加到的墙壁.
You can set an Anchor relative to the camera position - i.e. point the camera at the wall you want to attach to.
要获得正确的深度,您需要将相机保持在设定的预设距离处,或者添加向后和向前移动对象的功能.正如@Ali 提到的,你会有漂移,但这在这个时候很常见.
To get the depth right you would need to either hold the camera at a set preset distance, or else add the ability to move the object backwards and forwards. As @Ali mentioned you will have drift but that is common at this time.
下面的代码将在相机视图的中间添加锚点:
The code below will add the anchor in the middle of the camera view:
//Add an Anchor and a renderable in front of the camera
Session session = arFragment.getArSceneView().getSession();
float[] pos = { 0, 0, -1 };
float[] rotation = { 0, 0, 0, 1 };
Anchor anchor = session.createAnchor(new Pose(pos, rotation));
anchorNode = new AnchorNode(anchor);
anchorNode.setRenderable(andyRenderable);
anchorNode.setParent(arFragment.getArSceneView().getScene());
有关此问题的更多讨论,请参见此处:
See here for some more discussion around this:
该方法确实有效,您可以根据需要设置深度.
The approach does work, and you can set the depth as you want.
如果您确实还想前后移动可渲染对象,那么可能有更好的方法来做到这一点,但我找到的最可靠的方法,遵循单独的 GitHub 讨论中的建议,是删除锚点并创建一个新位置在新位置后面或前面的设置位置 - 即有一个按钮,允许用户将可渲染对象向后移动 0.1M 或向前移动 0.1M.
If you do want to also move the renderable forwards and backwards, then there may be better ways to do it, but the most reliable approach I found, following advise on a separate GitHub discussion, was to delete the anchor and create a new one in a set position behind or in front of new position - i.e. have a button which allows the user move the renderable back 0.1M or forwards 0.1M.
这篇关于ARCore – 如何在没有任何特征点的情况下在墙壁等表面上放置/创建对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!