ARCore –如何在没有任何特征点的表面(如墙壁)上放置/创建对象? [英] ARCore – How to place/create objects on surfaces like walls without any Feature Points?

查看:175
本文介绍了ARCore –如何在没有任何特征点的表面(如墙壁)上放置/创建对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:我感兴趣的是将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆