Obtain the device camera's Geospatial pose
Stay organized with collections
Save and categorize content based on your preferences.
Once you have configured your app's settings to use the Geospatial API, you can call ArEarth_getCameraGeospatialPose
to obtain a ArGeospatialPose
that describes the device’s Geospatial positioning for the camera in the latest frame. This pose, managed in an ArEarth
object, contains the following information:
- Location, expressed in latitude and longitude
- Altitude
- An orientation approximating the direction the user is facing in the EUS coordinate system with X+ pointing east, Y+ pointing up, and Z+ pointing south
Check the tracking state
Geospatial values are only valid while ArEarth.ArTrackingState
is ArTrackingState.AR_TRACKING_STATE_TRACKING
and ArEarth.ArEarthState
is AR_EARTH_STATE_ENABLED
. Make sure to wrap all Geospatial API calls in a ArEarth.ArTrackingState
control block.
if (ar_earth != NULL) {
ArTrackingState earth_tracking_state = AR_TRACKING_STATE_STOPPED;
ArTrackable_getTrackingState(ar_session, (ArTrackable*)ar_earth,
&earth_tracking_state);
if (earth_tracking_state == AR_TRACKING_STATE_TRACKING) {
ArGeospatialPose* camera_geospatial_pose = NULL;
ArGeospatialPose_create(ar_session, &camera_geospatial_pose);
ArEarth_getCameraGeospatialPose(ar_session, ar_earth,
camera_geospatial_pose);
// camera_geospatial_pose contains geodetic location, rotation, and
// confidences values.
ArGeospatialPose_destroy(camera_geospatial_pose);
}
}
If ArEarth.ArTrackingState
does not become ArTrackingState.AR_TRACKING_STATE_TRACKING
, ArEarth.ArTrackingState
may be AR_TRACKING_STATE_PAUSED
or AR_TRACKING_STATE_STOPPED
. If neither of these conditions are true, check ArEarth.ArEarthState
, which shows other error states that may keep the ArEarth
object from tracking.
Adjust the pose for accuracy
When the device is upright in the default orientation, the pitch (X+) and roll (Z+) angles tend to be precise due to a natural alignment with AR tracking. However, the yaw (Y+) angles can vary depending on VPS data availability and temporal conditions at the location. Your app may have to make adjustments for accuracy.
ArGeospatialPose_getOrientationYawAccuracy()
provides an accuracy estimate for the yaw (Y+) angles for a certain ArGeospatialPose
. The orientation yaw accuracy is a number that describes the radius, in degrees, of the 68th percentile confidence level around the yaw angles returned from ArGeospatialPose_getEastUpSouthQuaternion()
. In other words, there is a 68% chance that the ArGeospatialPose
’s true yaw angle is accurate.
Larger values indicate lower accuracy. For example, if the estimated yaw angle is 60 degrees and the yaw accuracy is 10 degrees, then there is a 68% probability that the true yaw angle is between 50 and 70 degrees.
What's next
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-14 UTC.
[null,null,["Last updated 2025-07-14 UTC."],[[["\u003cp\u003eAfter configuring your app, call \u003ccode\u003eArEarth_getCameraGeospatialPose\u003c/code\u003e to obtain the device's geospatial positioning, including location (latitude, longitude), altitude, and orientation, through an \u003ccode\u003eArGeospatialPose\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eGeospatial values are only valid when \u003ccode\u003eArEarth.ArTrackingState\u003c/code\u003e is \u003ccode\u003eAR_TRACKING_STATE_TRACKING\u003c/code\u003e and \u003ccode\u003eArEarth.ArEarthState\u003c/code\u003e is \u003ccode\u003eAR_EARTH_STATE_ENABLED\u003c/code\u003e, requiring you to wrap API calls in a tracking state control block.\u003c/p\u003e\n"],["\u003cp\u003eWhile pitch and roll angles tend to be accurate, yaw angles may vary and require adjustments using the \u003ccode\u003eArGeospatialPose_getOrientationYawAccuracy\u003c/code\u003e function to assess accuracy and confidence levels.\u003c/p\u003e\n"]]],["After configuring app settings, call `ArEarth_getCameraGeospatialPose` to get the device's geospatial position (`ArGeospatialPose`). This pose contains latitude, longitude, altitude, and orientation. Geospatial data is valid only when `ArTrackingState` is `AR_TRACKING_STATE_TRACKING` and `ArEarthState` is `AR_EARTH_STATE_ENABLED`. Ensure API calls are within a `ArTrackingState` control block. The yaw angle's accuracy can vary; `ArGeospatialPose_getOrientationYawAccuracy` estimates its precision. Larger values of accuracy indicate lower precision of the Yaw angle.\n"],null,["# Obtain the device camera's Geospatial pose\n\nOnce you have configured your app's settings to use the Geospatial API, you can call [`ArEarth_getCameraGeospatialPose`](/ar/reference/c/group/ar-earth#arearth_getcamerageospatialpose) to obtain a [`ArGeospatialPose`](/ar/reference/c/group/ar-geospatial-pose) that describes the device's Geospatial positioning for the camera in the latest frame. This pose, managed in an [`ArEarth`](/ar/reference/c/group/ar-earth) object, contains the following information:\n\n- Location, expressed in latitude and longitude\n- Altitude\n- An orientation approximating the direction the user is facing in the EUS coordinate system with X+ pointing east, Y+ pointing up, and Z+ pointing south\n\nCheck the tracking state\n------------------------\n\nGeospatial values are only valid while [`ArEarth.ArTrackingState`](/ar/reference/c/group/shared-types#artrackingstate) is [`ArTrackingState.AR_TRACKING_STATE_TRACKING`](/ar/reference/c/group/shared-types#artrackingstate) and [`ArEarth.ArEarthState`](/ar/reference/c/group/ar-earth#arearthstate) is [`AR_EARTH_STATE_ENABLED`](/ar/reference/c/group/ar-earth#arearthstate). Make sure to wrap all Geospatial API calls in a [`ArEarth.ArTrackingState`](/ar/reference/c/group/shared-types#artrackingstate) control block. \n\n```c\nif (ar_earth != NULL) {\n ArTrackingState earth_tracking_state = AR_TRACKING_STATE_STOPPED;\n ArTrackable_getTrackingState(ar_session, (ArTrackable*)ar_earth,\n &earth_tracking_state);\n if (earth_tracking_state == AR_TRACKING_STATE_TRACKING) {\n ArGeospatialPose* camera_geospatial_pose = NULL;\n ArGeospatialPose_create(ar_session, &camera_geospatial_pose);\n ArEarth_getCameraGeospatialPose(ar_session, ar_earth,\n camera_geospatial_pose);\n // camera_geospatial_pose contains geodetic location, rotation, and\n // confidences values.\n ArGeospatialPose_destroy(camera_geospatial_pose);\n }\n}\n```\n\nIf [`ArEarth.ArTrackingState`](/ar/reference/c/group/shared-types#artrackingstate) does not become [`ArTrackingState.AR_TRACKING_STATE_TRACKING`](/ar/reference/c/group/shared-types#artrackingstate), [`ArEarth.ArTrackingState`](/ar/reference/c/group/shared-types#artrackingstate) may be [`AR_TRACKING_STATE_PAUSED`](/ar/reference/c/group/shared-types#artrackingstate) or [`AR_TRACKING_STATE_STOPPED`](/ar/reference/c/group/shared-types#artrackingstate). If neither of these conditions are true, check [`ArEarth.ArEarthState`](/ar/reference/c/group/ar-earth#arearthstate), which shows other error states that may keep the [`ArEarth`](/ar/reference/c/group/ar-earth) object from tracking.\n\nAdjust the pose for accuracy\n----------------------------\n\nWhen the device is upright in the default orientation, the pitch (X+) and roll (Z+) angles tend to be precise due to a natural alignment with AR tracking. However, the yaw (Y+) angles can vary depending on VPS data availability and temporal conditions at the location. Your app may have to make adjustments for accuracy.\n\n[`ArGeospatialPose_getOrientationYawAccuracy()`](/ar/reference/c/group/ar-earth#argeospatialpose_getorientationyawaccuracy) provides an accuracy estimate for the yaw (Y+) angles for a certain [`ArGeospatialPose`](/ar/reference/c/group/ar-geospatial-pose). The orientation yaw accuracy is a number that describes the radius, in degrees, of the 68th percentile confidence level around the yaw angles returned from [`ArGeospatialPose_getEastUpSouthQuaternion()`](/ar/reference/c/group/ar-geospatial-pose#argeospatialpose_geteastupsouthquaternion). In other words, there is a 68% chance that the [`ArGeospatialPose`](/ar/reference/c/group/ar-geospatial-pose)'s true yaw angle is accurate.\n\nLarger values indicate lower accuracy. For example, if the estimated yaw angle is 60 degrees and the yaw accuracy is 10 degrees, then there is a 68% probability that the true yaw angle is between 50 and 70 degrees.\n\nWhat's next\n-----------\n\n- Place a [Geospatial anchor](/ar/develop/c/geospatial/anchors#wgs84_anchors) by obtaining the anchor's Geospatial pose."]]