Skip to content

Commit

Permalink
ARCore Android SDK v1.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyvc authored and devbridie committed May 11, 2022
1 parent e271aa3 commit e28822d
Show file tree
Hide file tree
Showing 151 changed files with 168,294 additions and 378 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ releases](https://github.com/google-ar/arcore-android-sdk/releases)

are licensed as follows:

Covered by the **Google APIs Terms of Service** at
[https://developers.google.com/terms/](https://developers.google.com/terms/)
Governed by the **ARCore Additional Terms of Service** at
[https://developers.google.com/ar/develop/terms](https://developers.google.com/ar/develop/terms)

===============================================================================
Section 2: ARCore SDK source files
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ The SDK release notes are available on the
## Terms & Conditions

By downloading the ARCore SDK for Android, you agree that the
[Google APIs Terms of Service](//developers.google.com/terms/) governs your use
thereof.
[**ARCore Additional Terms of Service**](https://developers.google.com/ar/develop/terms)
governs your use thereof.


## User privacy requirements
Expand Down
735 changes: 722 additions & 13 deletions libraries/include/arcore_c_api.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/augmented_faces_java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {

dependencies {
// ARCore (Google Play Services for AR) library.
implementation 'com.google.ar:core:1.30.0'
implementation 'com.google.ar:core:1.31.0'

// Obj - a simple Wavefront OBJ file loader
// https://github.com/javagl/Obj
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
precision mediump float;

uniform sampler2D u_DepthTexture;
uniform sampler2D u_ColorMap;

varying vec2 v_TexCoord;

const highp float kMaxDepth = 8000.0; // In millimeters.
const float kMidDepthMeters = 8.0;
const float kMaxDepthMeters = 30.0;

float DepthGetMillimeters(in sampler2D depth_texture, in vec2 depth_uv) {
// Depth is packed into the red and green components of its texture.
Expand All @@ -29,37 +31,39 @@ float DepthGetMillimeters(in sampler2D depth_texture, in vec2 depth_uv) {
return dot(packedDepthAndVisibility.xy, vec2(255.0, 256.0 * 255.0));
}

// Returns a color corresponding to the depth passed in. Colors range from red
// to green to blue, where red is closest and blue is farthest.
//
// Uses Turbo color mapping:
// https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
vec3 DepthGetColorVisualization(in float x) {
const vec4 kRedVec4 = vec4(0.55305649, 3.00913185, -5.46192616, -11.11819092);
const vec4 kGreenVec4 = vec4(0.16207513, 0.17712472, 15.24091500, -36.50657960);
const vec4 kBlueVec4 = vec4(-0.05195877, 5.18000081, -30.94853351, 81.96403246);
const vec2 kRedVec2 = vec2(27.81927491, -14.87899417);
const vec2 kGreenVec2 = vec2(25.95549545, -5.02738237);
const vec2 kBlueVec2 = vec2(-86.53476570, 30.23299484);
const float kInvalidDepthThreshold = 0.01;

// Adjusts color space via 6 degree poly interpolation to avoid pure red.
x = clamp(x * 0.9 + 0.03, 0.0, 1.0);
vec4 v4 = vec4(1.0, x, x * x, x * x * x);
vec2 v2 = v4.zw * v4.z;
vec3 polynomial_color = vec3(
dot(v4, kRedVec4) + dot(v2, kRedVec2),
dot(v4, kGreenVec4) + dot(v2, kGreenVec2),
dot(v4, kBlueVec4) + dot(v2, kBlueVec2)
);
// Returns linear interpolation position of value between min and max bounds.
// E.g. InverseLerp(1100, 1000, 2000) returns 0.1.
float InverseLerp(float value, float min_bound, float max_bound) {
return clamp((value - min_bound) / (max_bound - min_bound), 0.0, 1.0);
}

return step(kInvalidDepthThreshold, x) * polynomial_color;
// Returns a color corresponding to the depth passed in.
// The input x is normalized in range 0 to 1.
vec3 DepthGetColorVisualization(in float x) {
return texture2D(u_ColorMap, vec2(x, 0.5)).rgb;
}

void main() {
highp float normalized_depth =
clamp(DepthGetMillimeters(u_DepthTexture, v_TexCoord.xy) / kMaxDepth,
0.0, 1.0);
// Interpolating in units of meters is more stable, due to limited floating
// point precision on GPU.
float depth_mm = DepthGetMillimeters(u_DepthTexture, v_TexCoord.xy);
float depth_meters = depth_mm * 0.001;

// Selects the portion of the color palette to use.
float normalized_depth = 0.0;
if (depth_meters < kMidDepthMeters) {
// Short-range depth (0m to 8m) maps to first half of the color palette.
normalized_depth = InverseLerp(depth_meters, 0.0, kMidDepthMeters) * 0.5;
} else {
// Long-range depth (8m to 30m) maps to second half of the color palette.
normalized_depth =
InverseLerp(depth_meters, kMidDepthMeters, kMaxDepthMeters) * 0.5 + 0.5;
}

// Converts depth to color by with the selected value in the color map.
vec4 depth_color = vec4(DepthGetColorVisualization(normalized_depth), 1.0);

// Invalid depth (pixels with value 0) mapped to black.
depth_color.rgb *= sign(depth_meters);
gl_FragColor = depth_color;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.ar.core.examples.java.common.helpers;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.provider.Settings;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

/** Helper to ask location permission. */
public final class LocationPermissionHelper {
private static final int LOCATION_PERMISSION_CODE = 1;
private static final String LOCATION_PERMISSION = Manifest.permission.ACCESS_FINE_LOCATION;

/** Check to see we have the necessary permissions for this app. */
public static boolean hasFineLocationPermission(Activity activity) {
return ContextCompat.checkSelfPermission(activity, LOCATION_PERMISSION)
== PackageManager.PERMISSION_GRANTED;
}

/** Check to see we have the necessary permissions for this app, and ask for them if we don't. */
public static void requestFineLocationPermission(Activity activity) {
ActivityCompat.requestPermissions(
activity, new String[] {LOCATION_PERMISSION}, LOCATION_PERMISSION_CODE);
}

/** Check to see if the array of given permissions contain the location permission. */
public static boolean hasFineLocationPermissionsResponseInResult(String[] permissions) {
for (String permission : permissions) {
if (LOCATION_PERMISSION.equals(permission)) {
return true;
}
}

return false;
}

/** Check to see if we need to show the rationale for this permission. */
public static boolean shouldShowRequestPermissionRationale(Activity activity) {
return ActivityCompat.shouldShowRequestPermissionRationale(activity, LOCATION_PERMISSION);
}

/** Launch Application Setting to grant permission. */
public static void launchPermissionSettings(Activity activity) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
activity.startActivity(intent);
}
}
4 changes: 2 additions & 2 deletions samples/augmented_image_c/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ android {

dependencies {
// ARCore (Google Play Services for AR) library.
implementation 'com.google.ar:core:1.30.0'
natives 'com.google.ar:core:1.30.0'
implementation 'com.google.ar:core:1.31.0'
natives 'com.google.ar:core:1.31.0'

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
precision mediump float;

uniform sampler2D u_DepthTexture;
uniform sampler2D u_ColorMap;

varying vec2 v_TexCoord;

const highp float kMaxDepth = 8000.0; // In millimeters.
const float kMidDepthMeters = 8.0;
const float kMaxDepthMeters = 30.0;

float DepthGetMillimeters(in sampler2D depth_texture, in vec2 depth_uv) {
// Depth is packed into the red and green components of its texture.
Expand All @@ -29,37 +31,39 @@ float DepthGetMillimeters(in sampler2D depth_texture, in vec2 depth_uv) {
return dot(packedDepthAndVisibility.xy, vec2(255.0, 256.0 * 255.0));
}

// Returns a color corresponding to the depth passed in. Colors range from red
// to green to blue, where red is closest and blue is farthest.
//
// Uses Turbo color mapping:
// https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
vec3 DepthGetColorVisualization(in float x) {
const vec4 kRedVec4 = vec4(0.55305649, 3.00913185, -5.46192616, -11.11819092);
const vec4 kGreenVec4 = vec4(0.16207513, 0.17712472, 15.24091500, -36.50657960);
const vec4 kBlueVec4 = vec4(-0.05195877, 5.18000081, -30.94853351, 81.96403246);
const vec2 kRedVec2 = vec2(27.81927491, -14.87899417);
const vec2 kGreenVec2 = vec2(25.95549545, -5.02738237);
const vec2 kBlueVec2 = vec2(-86.53476570, 30.23299484);
const float kInvalidDepthThreshold = 0.01;

// Adjusts color space via 6 degree poly interpolation to avoid pure red.
x = clamp(x * 0.9 + 0.03, 0.0, 1.0);
vec4 v4 = vec4(1.0, x, x * x, x * x * x);
vec2 v2 = v4.zw * v4.z;
vec3 polynomial_color = vec3(
dot(v4, kRedVec4) + dot(v2, kRedVec2),
dot(v4, kGreenVec4) + dot(v2, kGreenVec2),
dot(v4, kBlueVec4) + dot(v2, kBlueVec2)
);
// Returns linear interpolation position of value between min and max bounds.
// E.g. InverseLerp(1100, 1000, 2000) returns 0.1.
float InverseLerp(float value, float min_bound, float max_bound) {
return clamp((value - min_bound) / (max_bound - min_bound), 0.0, 1.0);
}

return step(kInvalidDepthThreshold, x) * polynomial_color;
// Returns a color corresponding to the depth passed in.
// The input x is normalized in range 0 to 1.
vec3 DepthGetColorVisualization(in float x) {
return texture2D(u_ColorMap, vec2(x, 0.5)).rgb;
}

void main() {
highp float normalized_depth =
clamp(DepthGetMillimeters(u_DepthTexture, v_TexCoord.xy) / kMaxDepth,
0.0, 1.0);
// Interpolating in units of meters is more stable, due to limited floating
// point precision on GPU.
float depth_mm = DepthGetMillimeters(u_DepthTexture, v_TexCoord.xy);
float depth_meters = depth_mm * 0.001;

// Selects the portion of the color palette to use.
float normalized_depth = 0.0;
if (depth_meters < kMidDepthMeters) {
// Short-range depth (0m to 8m) maps to first half of the color palette.
normalized_depth = InverseLerp(depth_meters, 0.0, kMidDepthMeters) * 0.5;
} else {
// Long-range depth (8m to 30m) maps to second half of the color palette.
normalized_depth =
InverseLerp(depth_meters, kMidDepthMeters, kMaxDepthMeters) * 0.5 + 0.5;
}

// Converts depth to color by with the selected value in the color map.
vec4 depth_color = vec4(DepthGetColorVisualization(normalized_depth), 1.0);

// Invalid depth (pixels with value 0) mapped to black.
depth_color.rgb *= sign(depth_meters);
gl_FragColor = depth_color;
}
2 changes: 1 addition & 1 deletion samples/augmented_image_java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {

dependencies {
// ARCore (Google Play Services for AR) library.
implementation 'com.google.ar:core:1.30.0'
implementation 'com.google.ar:core:1.31.0'

// Obj - a simple Wavefront OBJ file loader
// https://github.com/javagl/Obj
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
precision mediump float;

uniform sampler2D u_DepthTexture;
uniform sampler2D u_ColorMap;

varying vec2 v_TexCoord;

const highp float kMaxDepth = 8000.0; // In millimeters.
const float kMidDepthMeters = 8.0;
const float kMaxDepthMeters = 30.0;

float DepthGetMillimeters(in sampler2D depth_texture, in vec2 depth_uv) {
// Depth is packed into the red and green components of its texture.
Expand All @@ -29,37 +31,39 @@ float DepthGetMillimeters(in sampler2D depth_texture, in vec2 depth_uv) {
return dot(packedDepthAndVisibility.xy, vec2(255.0, 256.0 * 255.0));
}

// Returns a color corresponding to the depth passed in. Colors range from red
// to green to blue, where red is closest and blue is farthest.
//
// Uses Turbo color mapping:
// https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
vec3 DepthGetColorVisualization(in float x) {
const vec4 kRedVec4 = vec4(0.55305649, 3.00913185, -5.46192616, -11.11819092);
const vec4 kGreenVec4 = vec4(0.16207513, 0.17712472, 15.24091500, -36.50657960);
const vec4 kBlueVec4 = vec4(-0.05195877, 5.18000081, -30.94853351, 81.96403246);
const vec2 kRedVec2 = vec2(27.81927491, -14.87899417);
const vec2 kGreenVec2 = vec2(25.95549545, -5.02738237);
const vec2 kBlueVec2 = vec2(-86.53476570, 30.23299484);
const float kInvalidDepthThreshold = 0.01;

// Adjusts color space via 6 degree poly interpolation to avoid pure red.
x = clamp(x * 0.9 + 0.03, 0.0, 1.0);
vec4 v4 = vec4(1.0, x, x * x, x * x * x);
vec2 v2 = v4.zw * v4.z;
vec3 polynomial_color = vec3(
dot(v4, kRedVec4) + dot(v2, kRedVec2),
dot(v4, kGreenVec4) + dot(v2, kGreenVec2),
dot(v4, kBlueVec4) + dot(v2, kBlueVec2)
);
// Returns linear interpolation position of value between min and max bounds.
// E.g. InverseLerp(1100, 1000, 2000) returns 0.1.
float InverseLerp(float value, float min_bound, float max_bound) {
return clamp((value - min_bound) / (max_bound - min_bound), 0.0, 1.0);
}

return step(kInvalidDepthThreshold, x) * polynomial_color;
// Returns a color corresponding to the depth passed in.
// The input x is normalized in range 0 to 1.
vec3 DepthGetColorVisualization(in float x) {
return texture2D(u_ColorMap, vec2(x, 0.5)).rgb;
}

void main() {
highp float normalized_depth =
clamp(DepthGetMillimeters(u_DepthTexture, v_TexCoord.xy) / kMaxDepth,
0.0, 1.0);
// Interpolating in units of meters is more stable, due to limited floating
// point precision on GPU.
float depth_mm = DepthGetMillimeters(u_DepthTexture, v_TexCoord.xy);
float depth_meters = depth_mm * 0.001;

// Selects the portion of the color palette to use.
float normalized_depth = 0.0;
if (depth_meters < kMidDepthMeters) {
// Short-range depth (0m to 8m) maps to first half of the color palette.
normalized_depth = InverseLerp(depth_meters, 0.0, kMidDepthMeters) * 0.5;
} else {
// Long-range depth (8m to 30m) maps to second half of the color palette.
normalized_depth =
InverseLerp(depth_meters, kMidDepthMeters, kMaxDepthMeters) * 0.5 + 0.5;
}

// Converts depth to color by with the selected value in the color map.
vec4 depth_color = vec4(DepthGetColorVisualization(normalized_depth), 1.0);

// Invalid depth (pixels with value 0) mapped to black.
depth_color.rgb *= sign(depth_meters);
gl_FragColor = depth_color;
}
Loading

0 comments on commit e28822d

Please sign in to comment.