Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

Commit

Permalink
release vega
Browse files Browse the repository at this point in the history
  • Loading branch information
jguomoto committed Aug 30, 2016
1 parent 9c6376e commit cb09679
Show file tree
Hide file tree
Showing 46 changed files with 1,974 additions and 78 deletions.
Binary file modified TangoReleaseLibs/aar/tango-ux-support-library.aar
Binary file not shown.
Binary file modified TangoReleaseLibs/aar/tango_support_java_lib.aar
Binary file not shown.
Binary file modified TangoReleaseLibs/jar/tango_java_lib.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.atap.tangoservice.TangoErrorException;
import com.google.atap.tangoservice.TangoEvent;
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPointCloudData;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;

Expand Down Expand Up @@ -208,6 +209,11 @@ public void onXyzIjAvailable(TangoXyzIjData xyzIj) {
// We are not using onXyzIjAvailable for this app.
}

@Override
public void onPointCloudAvailable(TangoPointCloudData pointCloud) {
// We are not using onPointCloudAvailable for this app.
}

@Override
public void onTangoEvent(TangoEvent event) {
// We are not using onTangoEvent for this app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.atap.tangoservice.TangoEvent;
import com.google.atap.tangoservice.TangoInvalidException;
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPointCloudData;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;

Expand Down Expand Up @@ -269,8 +270,13 @@ public void run() {
}

@Override
public void onXyzIjAvailable(TangoXyzIjData xyzij) {
// We are not using TangoXyzIjData for this application.
public void onXyzIjAvailable(TangoXyzIjData xyzIj) {
// We are not using onXyzIjAvailable for this app.
}

@Override
public void onPointCloudAvailable(TangoPointCloudData xyzij) {
// We are not using onPointCloudAvailable for this app.
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.atap.tangoservice.TangoErrorException;
import com.google.atap.tangoservice.TangoEvent;
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPointCloudData;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;

Expand All @@ -35,7 +36,7 @@

/**
* Main Activity class for the Depth Perception Sample. Handles the connection to the {@link Tango}
* service and propagation of Tango XyzIj data to Layout view.
* service and propagation of Tango PointCloud data to Layout view.
*/
public class HelloDepthPerceptionActivity extends Activity {

Expand Down Expand Up @@ -107,6 +108,7 @@ private TangoConfig setupTangoConfig(Tango tango) {
TangoConfig config = new TangoConfig();
config = tango.getConfig(config.CONFIG_TYPE_DEFAULT);
config.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);
config.putInt(TangoConfig.KEY_INT_DEPTH_MODE, TangoConfig.TANGO_DEPTH_MODE_POINT_CLOUD);
return config;
}

Expand All @@ -131,8 +133,13 @@ public void onPoseAvailable(final TangoPoseData pose) {
}

@Override
public void onXyzIjAvailable(final TangoXyzIjData xyzIjData) {
logXyzIj(xyzIjData);
public void onXyzIjAvailable(TangoXyzIjData xyzIj) {
// We are not using onXyzIjAvailable for this app.
}

@Override
public void onPointCloudAvailable(final TangoPointCloudData pointCloudData) {
logPointCloud(pointCloudData);
}

@Override
Expand All @@ -148,28 +155,29 @@ public void onFrameAvailable(int cameraId) {
}

/**
* Log the point count and the average depth of the given XyzIj data
* Log the point count and the average depth of the given PointCloud data
* in the Logcat as information.
*/
private void logXyzIj(TangoXyzIjData xyzIjData) {
private void logPointCloud(TangoPointCloudData pointCloudData) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Point count: " + xyzIjData.xyzCount);
stringBuilder.append(". Average depth (m): " + calculateAveragedDepth(xyzIjData.xyz));
stringBuilder.append("Point count: " + pointCloudData.numPoints);
stringBuilder.append(". Average depth (m): " +
calculateAveragedDepth(pointCloudData.points, pointCloudData.numPoints));
Log.i(TAG, stringBuilder.toString());
}

/**
* Calculates the average depth from a point cloud buffer.
*/
private float calculateAveragedDepth(FloatBuffer pointCloudBuffer) {
int pointCount = pointCloudBuffer.capacity() / 3;
private float calculateAveragedDepth(FloatBuffer pointCloudBuffer, int numPoints) {
float totalZ = 0;
float averageZ = 0;
for (int i = 0; i < pointCloudBuffer.capacity() - 3; i = i + 3) {
totalZ = totalZ + pointCloudBuffer.get(i + 2);
}
if (pointCount != 0) {
averageZ = totalZ / pointCount;
if (numPoints != 0) {
int numFloats = 4 * numPoints;
for (int i = 2; i < numFloats; i = i + 4) {
totalZ = totalZ + pointCloudBuffer.get(i);
}
averageZ = totalZ / numPoints;
}
return averageZ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.atap.tangoservice.TangoErrorException;
import com.google.atap.tangoservice.TangoEvent;
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPointCloudData;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;

Expand Down Expand Up @@ -133,8 +134,13 @@ public void onPoseAvailable(final TangoPoseData pose) {
}

@Override
public void onXyzIjAvailable(TangoXyzIjData arg0) {
// We are not using TangoXyzIjData for this application.
public void onXyzIjAvailable(TangoXyzIjData xyzIj) {
// We are not using onXyzIjAvailable for this app.
}

@Override
public void onPointCloudAvailable(TangoPointCloudData pointCloud) {
// We are not using onPointCloudAvailable for this app.
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.atap.tangoservice.TangoErrorException;
import com.google.atap.tangoservice.TangoEvent;
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPointCloudData;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;

Expand Down Expand Up @@ -171,8 +172,13 @@ public void onPoseAvailable(final TangoPoseData pose) {
}

@Override
public void onXyzIjAvailable(final TangoXyzIjData xyzIjData) {
// We are not using TangoXyzIjData for this application.
public void onXyzIjAvailable(TangoXyzIjData xyzIj) {
// We are not using onXyzIjAvailable for this app.
}

@Override
public void onPointCloudAvailable(final TangoPointCloudData pointCloudData) {
// We are not using onPointCloudAvailable for this app.
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.atap.tangoservice.TangoEvent;
import com.google.atap.tangoservice.TangoException;
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPointCloudData;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;

Expand Down Expand Up @@ -212,6 +213,7 @@ private void connectTango() {
// objects with the RBG image and produce a good AR effect.
config.putBoolean(TangoConfig.KEY_BOOLEAN_LOWLATENCYIMUINTEGRATION, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);
config.putInt(TangoConfig.KEY_INT_DEPTH_MODE, TangoConfig.TANGO_DEPTH_MODE_POINT_CLOUD);
// NOTE: Area learning is necessary to achieve better precision is pose estimation
config.putBoolean(TangoConfig.KEY_BOOLEAN_LEARNINGMODE, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_COLORCAMERA, true);
Expand Down Expand Up @@ -239,8 +241,13 @@ public void onFrameAvailable(int cameraId) {

@Override
public void onXyzIjAvailable(TangoXyzIjData xyzIj) {
// We are not using onXyzIjAvailable for this app.
}

@Override
public void onPointCloudAvailable(TangoPointCloudData pointCloud) {
// Save the cloud and point data for later use.
mPointCloudManager.updateXyzIj(xyzIj);
mPointCloudManager.updatePointCloud(pointCloud);
}

@Override
Expand Down Expand Up @@ -417,9 +424,9 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
* It returns the pose of the fitted plane in a TangoPoseData structure.
*/
private WallMeasurement doWallMeasurement(float u, float v, double rgbTimestamp) {
TangoXyzIjData xyzIj = mPointCloudManager.getLatestXyzIj();
TangoPointCloudData pointCloud = mPointCloudManager.getLatestPointCloud();

if (xyzIj == null) {
if (pointCloud == null) {
return null;
}

Expand All @@ -428,17 +435,17 @@ private WallMeasurement doWallMeasurement(float u, float v, double rgbTimestamp)
// cloud was acquired.
TangoPoseData colorTdepthPose = TangoSupport.calculateRelativePose(
rgbTimestamp, TangoPoseData.COORDINATE_FRAME_CAMERA_COLOR,
xyzIj.timestamp, TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH);
pointCloud.timestamp, TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH);

// Perform plane fitting with the latest available point cloud data.
try {
IntersectionPointPlaneModelPair intersectionPointPlaneModelPair =
TangoSupport.fitPlaneModelNearClick(xyzIj, mIntrinsics,
TangoSupport.fitPlaneModelNearPoint(pointCloud,
colorTdepthPose, u, v);

// Get the depth camera transform at the time the plane data was acquired.
TangoSupport.TangoMatrixTransformData transform =
TangoSupport.getMatrixTransformAtTime(xyzIj.timestamp,
TangoSupport.getMatrixTransformAtTime(pointCloud.timestamp,
TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION,
TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH,
TangoSupport.TANGO_SUPPORT_ENGINE_OPENGL,
Expand All @@ -449,10 +456,12 @@ private WallMeasurement doWallMeasurement(float u, float v, double rgbTimestamp)
intersectionPointPlaneModelPair.intersectionPoint,
intersectionPointPlaneModelPair.planeModel, transform.matrix);

return new WallMeasurement(planeFitTransform, transform.matrix, xyzIj.timestamp);
return new WallMeasurement(planeFitTransform,
transform.matrix,
pointCloud.timestamp);
} else {
Log.d(TAG, "Could not get a valid transform from depth to area description at time "
+ xyzIj.timestamp);
+ pointCloud.timestamp);
}
} catch (TangoException e) {
Log.d(TAG, "Failed to fit plane");
Expand Down
7 changes: 7 additions & 0 deletions java_green_screen_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.gradle
local.properties
.idea
*.iml
.DS_Store
build
captures
1 change: 1 addition & 0 deletions java_green_screen_example/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
43 changes: 43 additions & 0 deletions java_green_screen_example/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.projecttango.examples.java.greenscreen"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}

def external_lib_prefix = null
if (project.hasProperty("Tango.catkin_devel_prefix")) {
external_lib_prefix = project.property("Tango.catkin_devel_prefix")
} else {
// Building in standalone sample form.
external_lib_prefix = "../../TangoReleaseLibs"
}

repositories {
flatDir {
dirs external_lib_prefix + '/aar'
}
}

dependencies {
compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])
compile (name: 'tango_support_java_lib', ext: 'aar')
compile 'com.android.support:design:23.4.0'
}
17 changes: 17 additions & 0 deletions java_green_screen_example/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /opt/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
47 changes: 47 additions & 0 deletions java_green_screen_example/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc.
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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.projecttango.examples.java.greenscreen"
android:versionCode="0"
android:versionName="0" >

<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library
android:name="com.projecttango.libtango_device2"
android:required="true" />
<activity
android:name="com.projecttango.examples.java.greenscreen.GreenScreenActivity"
android:label="@string/app_name_long" >
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit cb09679

Please sign in to comment.