[ Web Proxy ]
URL:
Viewing: https://developers.google.com/ar/develop/java/depth/quickstart [Back]  [Original]

Depth API quickstart for Android  |  ARCore  |  Google for Developers Skip to main content
Send feedback

Depth API quickstart for Android Stay organized with collections Save and categorize content based on your preferences.

outlined_flag

Prerequisites

Open the sample project

This quickstart uses OpenGL, a programming interface for rendering 2D and 3D vector graphics. Review Enable ARCore before getting started with the following steps.

Get the sample project by cloning the repository with the following command:

git clone https://github.com/google-ar/arcore-android-sdk.git

In Android Studio, open the hello_ar_java sample project, located in the samples subdirectory within the arcore-android-sdk directory.

Run the sample

The Depth API sample app lets you place virtual Android figures in your environment, and toggle occlusion to see the difference. It also lets you toggle the depth map visualization in a given space.

Note: The Depth API is not supported when running in the Android Emulator. Use a physical supported device to test the Depth API.

Make sure your Android device is connected to the development machine and click Run toolbar-run.png [toolbar-run.png] in Android Studio.

Your device may prompt you to install or update Google Play Services for AR if it is missing or out of date. Tap CONTINUE to install it from the Google Play Store.

Enable depth

The first time you run the app and place an Android figure, a dialog will prompt you to enable depth. It only appears the first time the app is run, for the first Android placed. Tap Enable to add occlusion.

Toggle occlusion and a visualization of the depth map

Tap the gear icon to toggle occlusion and a visualization of the depth map. Select Enable depth to enable occlusion. Select Show depth map to display a visualization of the depth map on the device's screen.

For example, the following images show a virtual Android figure in a real space containing a trunk beside a door. In the first image, the virtual Android unrealistically overlaps with the edge of the trunk. In the second image, the Android is properly occluded, appearing much more realistic in its surroundings.

The following images show a camera image of a hallway with a bicycle on the wall, and a visualization of the depth map that is created for that camera image.

Next steps

Start using the Depth API in your own apps. To learn more, see:

Send feedback

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 2024-10-31 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page