ARCore and Sceneform with Geolocation
Asked Answered
H

2

5

I have been reading around the documentation and the examples but still cant figure out a way to use ARCore/Sceneform with geolocations. An example would be opening my camera and according to my geo location and other places' geolocation I would render them on the camera if my camera was on the same compass direction as the object.

Can someone point me in the right direction of where I should be looking at and any guidance and is there something I can use from ARCore/Sceneform that would help with that?

Highjack answered 17/5, 2018 at 3:20 Comment(0)
C
2

ARCore's Geospatial API

With ARCore 1.31 Geospatial API you can obtain geospatial data from Google Earth 3D and Street View images (from Google Maps), to enable your ARCore app for global-scale location-based AR experiences. This data model, taken from billions of images, is provided with Google VPS.

To enable Geospatial API use the following code:

fun configureSession(session: Session) {
    session.configure(
        session.config.apply {
            geospatialMode = Config.GeospatialMode.ENABLED
        }
    )
}

Then check if an object's TrackingState is TRACKING:

val earth = session?.earth ?: return

if (earth.trackingState != TrackingState.TRACKING) { return }

Now, you're ready to determine a pose of a new anchor:

val altitude = earth.cameraGeospatialPose.altitudeMeters - 1

val qtrnX = 0f; val qtrnY = 0f; val qtrnZ = 0f; val qtrnW = 1f;

earthAnchor = earth.createAnchor(latLng.latitude, 
                                 latLng.longitude, 
                                 altitude, qtrnX, qtrnY, qtrnZ, qtrnW)

Geospatial supported areas

Before using the Geospatial API, make sure the area you are in is supported.

Chellean answered 12/5, 2022 at 10:17 Comment(5)
Hi Andy, is there any plan for you to write a sample project using geospatial API with SwiftUI + Realitykit in medium? I really want to learn how it works all together. Thanks Andy!Loomis
@AndyJazz when I place anchor with distance more than 200m it seem to disappear from my screen. Any work for this?Handyman
@DevMobApp, in ARCore + Sceneform use arFragment.getArSceneView().getScene().getCamera().setFarClipPlane(500). If you use different framework – read documentation...Chellean
Using openGL GLSurfaceView for rendering object. Any idea for this.Handyman
Read documentation.Chellean
C
0

I think there's nothing Sceneform specific to help you but I have some ideas: 1. The coordinate system is in meters which should help you to make the needed calculations. 2. You could let the user hold the device upright (check it via sensors) and get use the Camera pose to align it with all sensors you want to use like Compass and Geolocation. Position everything relative to this position. You maybe also want to create an Anchor to that position on order to keep everything updated as ARCore's understanding of the world improves.

Crosse answered 26/5, 2018 at 9:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.