ARCore – How to place/create objects on surfaces like walls without any Feature Points?
Asked Answered
S

4

6

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.

Sukiyaki answered 6/11, 2018 at 14:19 Comment(0)
S
6

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.

Supervision answered 6/11, 2018 at 15:55 Comment(1)
Thanks for this answer. I so love you for thisSlushy
B
3

As per ARCore-2020, placing an anchor at the position where the camera is currently at, can be done by using

session.createAnchor(camera.getPose());

or

session.createAnchor(camera.getDisplayOrientedPose());  

Because placing an anchor at

float[] pos = {0,0,-1};
float[] rotation = {0,0,0,1};
session.createAnchor(new Pose(pos, rotation));

creates an anchor at the global origin (where your session started).

Unless your hitresult can give you a trackable feature like a plane or a point, you can't create an anchor on a featureless wall.

If your application is designed for a specific use case, you can make some assumptions about the environment and formulate some vector relationship between an anchor which is at a featured area and a desired anchor at a feature less area.

For example. If you want to place an anchor on a wall, which doesn't have any features. (Provided the camera is always in a tracking state).

I would first place an anchor at any 3 of the walls a, b, c, where I know there's most definitely a feature point that is trackable.

Create a plane, using these 3 points, the math for which can be found here

https://sites.math.washington.edu/~king/coursedir/m445w04/notes/vector/equations.html

Now to get the equation of a line along the direction in which the camera is looking ->

if camera pose = X = {x,y,z} and Q = {qx,qy,qz,qw}, Then the equation of the line = {x,y,z} + LAMBDA (Q.{0,0,-1})

where LAMBDA is a random variable along the line. and Q.{0,0,-1} signifies the rotation of of {0,0,-1} with the quaternion Q

So now if you want to place an anchor on the wall. You would find the point of intersection between the camera line and the wall plane.

Byblow answered 7/9, 2020 at 6:35 Comment(0)
D
2

There are at least 5 different ways you can use for placing 3D objects in your scene. But any 3D geometry can't exist without an Anchor – an object's local coordinate system located at its pivot point.

The following approaches can be used for object's placement:

  • If plane detection is enabled, ARCore can automatically add Anchor to the current session.
  • When you tap on the screen allows you project a point onto an imaginary plane, placing Anchor.
  • ARCore Camera's transform (its location & orientation) can be used for placement of an Anchor.
  • Feature Points (points on a high-contrast's margins) can give you a place to put an Anchor to.
  • Clusters of Feature Points allow you to save a real world environment map for retrieving it later.

As you can see Feature points option aren't always used. Be creative and use all efficient methods for placing 3D in your scene.

Dynameter answered 7/11, 2018 at 0:37 Comment(0)
A
1

You can maybe anchor an object to any Trackable and then ask user to move until the wall. You calculate the distance and then you somehow have your depth perception of that wall from that trackable. You will see some drifts of course but that happens with ARCore all the time.

Acklin answered 6/11, 2018 at 14:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.