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

Commit

Permalink
release-ancha, fix motion tracking permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
r4ravi2008 committed Nov 12, 2015
1 parent 81a259e commit 6f3c94f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ protected void onResume() {
try {
mTango.connect(mConfig);
mIsTangoServiceConnected = true;
setupExtrinsics();
} catch (TangoOutOfDateException outDateEx) {
if (mTangoUx != null) {
mTangoUx.showTangoOutOfDate();
Expand All @@ -156,7 +157,6 @@ protected void onResume() {
Toast.makeText(getApplicationContext(), R.string.TangoError, Toast.LENGTH_SHORT)
.show();
}
setupExtrinsics();
Log.i(TAG, "onResumed");
}

Expand Down
4 changes: 2 additions & 2 deletions VideoOverlaySample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.projecttango.videooverlaysample"
package="com.projecttango.experiments.videooverlaysample"
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.CAMERA" />

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import com.google.atap.tangoservice.TangoCameraPreview;
import com.google.atap.tangoservice.TangoConfig;
import com.google.atap.tangoservice.TangoCoordinateFramePair;
import com.google.atap.tangoservice.TangoErrorException;
import com.google.atap.tangoservice.TangoEvent;
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;

Expand All @@ -48,7 +50,6 @@ public class MainActivity extends Activity {
private TangoCameraPreview tangoCameraPreview;
private Tango mTango;
private boolean mIsConnected;
private boolean mIsPermissionGranted;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -61,33 +62,17 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(tangoCameraPreview);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == Tango.TANGO_INTENT_ACTIVITYCODE) {
// Make sure the request was successful
if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Motion Tracking Permissions Required!",
Toast.LENGTH_SHORT).show();
finish();
} else {
startCameraPreview();
mIsPermissionGranted = true;
}
}
}

// Camera Preview
private void startCameraPreview() {
// Connect to color camera
// Connect to color camera
tangoCameraPreview.connectToTangoCamera(mTango,
TangoCameraIntrinsics.TANGO_CAMERA_COLOR);
// Use default configuration for Tango Service.
TangoConfig config = mTango.getConfig(TangoConfig.CONFIG_TYPE_DEFAULT);
mTango.connect(config);
mIsConnected = true;
// No need to add any coordinate frame pairs since we are not using

// No need to add any coordinate frame pairs since we are not using
// pose data. So just initialize.
ArrayList<TangoCoordinateFramePair> framePairs = new ArrayList<TangoCoordinateFramePair>();
mTango.connectListener(framePairs, new OnTangoUpdateListener() {
Expand All @@ -98,9 +83,9 @@ public void onPoseAvailable(TangoPoseData pose) {

@Override
public void onFrameAvailable(int cameraId) {
// Check if the frame available is for the camera we want and
// update its frame on the camera preview.

// Check if the frame available is for the camera we want and
// update its frame on the camera preview.
if (cameraId == TangoCameraIntrinsics.TANGO_CAMERA_COLOR) {
tangoCameraPreview.onFrameAvailable();
}
Expand Down Expand Up @@ -131,8 +116,15 @@ protected void onPause() {
@Override
protected void onResume() {
super.onResume();
if (!mIsConnected && mIsPermissionGranted) {
startCameraPreview();
try {
if (!mIsConnected) {
startCameraPreview();
}
} catch (TangoOutOfDateException e) {
Toast.makeText(getApplicationContext(), R.string.TangoOutOfDateException,
Toast.LENGTH_SHORT).show();
} catch (TangoErrorException e) {
Toast.makeText(getApplicationContext(), R.string.TangoError, Toast.LENGTH_SHORT).show();
}
}
}
4 changes: 4 additions & 0 deletions VideoOverlaySample/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
<string name="app_name">VideoOverlaySample</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="TangoError">"Tango exception! Try again!"</string>
<string name="TangoOutOfDateException">"Tango service outdated!"</string>
<string name="resetmotiontracking">"Reset motion tracking"</string>
<string name="motiontrackingpermission">"Motion Tracking permission needed!"</string>

</resources>

0 comments on commit 6f3c94f

Please sign in to comment.