Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

java - ARCore – How to place/create objects on surfaces like walls without any Feature Points?

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?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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());

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...