ARCore – 如何在没有任何特征点的情况下在墙壁等表面上放置/创建对象?

Mur*_*dia 5 java android augmented-reality arcore sceneform

例如:我有兴趣在垂直平面上放置 2D 图像(例如:白色或单色墙,不存在特征点)。

有哪些不同的解决方法?

我知道 ARCore 支持相对于其他对象放置对象。如何扩展它以满足我将对象相对于未检测到特征点的其他对象放置的要求?

非常感谢任何想法或解决方法。

Mic*_*ick 5

You can set an Anchor relative to the camera position - i.e. point the camera at the wall you want to attach to.

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());
Run Code Online (Sandbox Code Playgroud)

See here for some more discussion around this:

The approach does work, and you can set the depth as you want.

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.


Ali*_*nat 1

您可以将对象锚定到任何可跟踪对象,然后要求用户移动到墙壁。你计算出距离,然后你就可以通过可追踪的方式获得对那堵墙的深度感知。当然,您会看到一些偏差,但 ARCore 总是会发生这种情况。