我一直在使用Tango使用修改过的TangoCameraPreview类来执行运动跟踪和相机进纸捕获。我最近需要在我的应用中添加深度感应功能。我开始修改TangoConfig,将KEY_BOOLEAN_DEPTH和KEY_INT_DEPTH_MODE设置为true。但是,应用程序开始崩溃,我甚至没有开始向onPointCloudAvailable()添加代码。我还收到以下错误消息。
04-01 23:32:15.088 5651-5664/edu.umich.engin.droplab.embeddeddatalogger A/art: art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String android.os.IBinder.getInterfaceDescriptor()' on a null object reference
04-01 23:32:15.088 5651-5664/edu.umich.engin.droplab.embeddeddatalogger A/art: art/runtime/java_vm_ext.cc:410] at void com.google.atap.tangoservice.TangoPointCloudData.readFromParcel(android.os.Parcel) (TangoPointCloudData.java:157)
04-01 23:32:15.088 5651-5664/edu.umich.engin.droplab.embeddeddatalogger A/art: art/runtime/java_vm_ext.cc:410] at void com.google.atap.tangoservice.TangoPointCloudData.<init>(android.os.Parcel) (TangoPointCloudData.java:112)
有谁知道我在做错了什么?谢谢!
2017年4月5日更新: 代码:
protected void onResume() {
super.onResume();
Log.i(TAG, "onResume");
if (askingPermission == false) {
if (!mGoogleApiClient.isConnected()) {
mGoogleApiClient.connect();
}
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(100);
mLocationRequest.setFastestInterval(100);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
.addLocationRequest(mLocationRequest);
PendingResult<LocationSettingsResult> result =
LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient,
builder.build());
result.setResultCallback(this);
startBackgroundThread();
if (mBackgroundLogger == null) {
mBackgroundLogger = new BackgroundLogger();
}
if (mPlayLocationListener == null) {
mPlayLocationListener = new PlayLocationListener();
}
sensorHandler.post(mBackgroundLogger);
sensorHandler.post(new recordButtonOnClickListener());
startNewTango();
}
}
protected void startNewTango(){
assert mTango == null;
mTango = new Tango(Recording.this, new Runnable() {
// Pass in a Runnable to be called from UI thread when Tango is ready, this Runnable
// will be running on a new thread.
// When Tango is ready, we can call Tango functions safely here only when there is no UI
// thread changes involved.
@Override
public void run() {
synchronized (Recording.this) {
try {
mConfig = setupTangoConfig(mTango);
mTango.connect(mConfig);
startupTango();
} catch (TangoOutOfDateException e) {
Log.e(TAG, getString(R.string.exception_out_of_date), e);
} catch (TangoErrorException e) {
Log.e(TAG, getString(R.string.exception_tango_error), e);
} catch (TangoInvalidException e) {
Log.e(TAG, getString(R.string.exception_tango_invalid), e);
}
}
}
});
}
private TangoConfig setupTangoConfig(Tango tango) {
// Create a new Tango Configuration and enable the HelloMotionTrackingActivity API.
TangoConfig config = tango.getConfig(TangoConfig.CONFIG_TYPE_DEFAULT);
config.putBoolean(TangoConfig.KEY_BOOLEAN_MOTIONTRACKING, true);
// Tango service should automatically attempt to recover when it enters an invalid state.
config.putBoolean(TangoConfig.KEY_BOOLEAN_AUTORECOVERY, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_COLORCAMERA, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_DRIFT_CORRECTION, true);
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);
return config;
}
private void startupTango() {
// Lock configuration and connect to Tango
// Select coordinate frame pair
final ArrayList<TangoCoordinateFramePair> framePairs =
new ArrayList<TangoCoordinateFramePair>();
framePairs.add(new TangoCoordinateFramePair(
TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
TangoPoseData.COORDINATE_FRAME_DEVICE));
mTangoCameraPreviewRecorder.connectToTangoCamera(mTango,TangoCameraIntrinsics.TANGO_CAMERA_COLOR);
// Listen for new Tango data
mTango.connectListener(framePairs, new OnTangoUpdateListener() {
@Override
public void onPoseAvailable(final TangoPoseData pose) {
//logPose(pose);
tangoPose = true;
tangoTranslation = pose.getTranslationAsFloats();
tangoOrientation = pose.getRotationAsFloats();
if(!firstFrame){
String csvString = "5,"+ System.currentTimeMillis()+","+tangoTranslation[0]+","+tangoTranslation[1]+","+tangoTranslation[2]+","+tangoOrientation[0]+","+tangoOrientation[1]+","+tangoOrientation[2]+","+tangoOrientation[3]+"\r\n";
csvWriteHandler.post(new CsvBackgroundWriter(csvString));
}
}
@Override
public void onXyzIjAvailable(TangoXyzIjData xyzIj) {
// We are not using onXyzIjAvailable for this app.
}
@Override
public void onPointCloudAvailable(TangoPointCloudData pointCloud) {
Log.i(TAG,"Point Cloud");
// We are not using onPointCloudAvailable for this app.
}
@Override
public void onTangoEvent(final TangoEvent event) {
// Ignoring TangoEvents.
}
@Override
public void onFrameAvailable(int cameraId) {
//Log.d(TAG, "onFrameAvailable");
mTangoCameraPreviewRecorder.onFrameAvailable();
if(isRecording){
if(firstFrame){
firstFrame = false;
String csvString = "First Frame:" + System.currentTimeMillis() + "\r\n";
csvString = "0:gyro,1:acc,2:linAcc,3:ori,4:gps, 5:Tango\r\n" + csvString;
csvWriteHandler.post(new CsvBackgroundWriter(csvString));
}
}
}
});
}