我正在尝试使用Google Tango Java API编写一个收集RGB和点云数据的应用程序。到目前为止,我设法使用TangoCameraPreview
在屏幕上显示来自RGB相机的图像,它似乎正在工作。但是,只要我将设备指向墙壁并且它开始捕获一些真实的深度,它会立即崩溃并出现以下异常:
I/tango_client_api: TangoErrorType TangoService_connectOnTangoEvent(void (*)(void*, const TangoEvent*), ...): Connecting callbacks...
I/tango_client_api: TangoErrorType TangoService_connectOnTangoEvent(void (*)(void*, const TangoEvent*), ...): Done connecting callbacks.
E/art: JNI ERROR (app bug): attempt to pass an instance of com.google.atap.tangoservice.TangoPointCloudData as argument 1 to void com.threedvideo.threedvideograbber.MainActivity$2.onXyzIjAvailable(com.google.atap.tangoservice.TangoXyzIjData)
A/art: art/runtime/check_jni.cc:64] JNI DETECTED ERROR IN APPLICATION: bad arguments passed to void com.threedvideo.threedvideograbber.MainActivity$2.onXyzIjAvailable(com.google.atap.tangoservice.TangoXyzIjData) (see above for details)
A/art: art/runtime/check_jni.cc:64] "Binder_3" prio=5 tid=17 Runnable
A/art: art/runtime/check_jni.cc:64] | group="main" sCount=0 dsCount=0 obj=0x64946ba0 self=0x4ab112f8
A/art: art/runtime/check_jni.cc:64] | sysTid=10535 nice=0 cgrp=apps sched=0/0 handle=0x4ab11028
A/art: art/runtime/check_jni.cc:64] | state=R schedstat=( 67362009 19616160 284 ) utm=3 stm=3 core=1 HZ=100
A/art: art/runtime/check_jni.cc:64] | stack=0x4ab81000-0x4ab85000 stackSize=1016KB
A/art: art/runtime/check_jni.cc:64] (no managed stack frames)
A/art: art/runtime/check_jni.cc:64]
A/art: art/runtime/runtime.cc:203] Runtime aborting...
A/art: art/runtime/runtime.cc:203] Aborting thread:
A/art: art/runtime/runtime.cc:203] "Binder_3" prio=5 tid=17 Runnable
| group="main" sCount=0 dsCount=0 obj=0x64946ba0 self=0x4ab112f8
| sysTid=10535 nice=0 cgrp=apps sched=0/0 handle=0x4ab11028
| state=R schedstat=( 67965509 19729327 285 ) utm=3 stm=3 core=1 HZ=100
| stack=0x4ab81000-0x4ab85000 stackSize=1016KB
native: art::Thread::DumpStack(std::ostream&) const+87 [0x41714b78] (libart.so)
native: ??? [0x4170cc62] (libart.so)
native: art::Runtime::Abort()+79 [0x4170d204] (libart.so)
native: art::LogMessage::~LogMessage()+507 [0x415b889c] (libart.so)
native: ??? [0x415c0ad4] (libart.so)
native: art::JniAbortF(char const*, char const*, ...)+51 [0x415c1254] (libart.so)
native: ??? [0x41667ee2] (libart.so)
native: ??? [0x41668444] (libart.so)
native: ??? [0x416c6e56] (libart.so)
native: ??? [0x415ca020] (libart.so)
native: _JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+19 [0x489d97c8] (libtango_client_api.so)
native: onXYZijParcelAvailable+217 [0x489d98d6] (libtango_client_api.so)
native: TangoListener::onXYZijParcelAvailable(android::Parcel const&)+47 [0x489cf8f8] (libtango_client_api.so)
native: Tango::ClientListener::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+261 [0x489dd0ee] (libtango_client_api.so)
native: android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+57 [0x401dc222] (libbinder.so)
native: android::IPCThreadState::executeCommand(int)+505 [0x401e0796] (libbinder.so)
native: android::IPCThreadState::getAndExecuteCommand()+37 [0x401e0b16] (libbinder.so)
native: android::IPCThreadState::joinThreadPool(bool)+47 [0x401e0b8c] (libbinder.so)
native: ??? [0x401e49a8] (libbinder.so)
native: android::Thread::_threadLoop(void*)+213 [0x401afa56] (libutils.so)
native: android::AndroidRuntime::javaThreadShell(void*)+65 [0x4023ceae] (libandroid_runtime.so)
native: ??? [0x401af588] (libutils.so)
native: __thread_entry+72 [0x401341b0] (libc.so)
native: pthread_create+240 [0x40134348] (libc.so)
(no managed stack frames)
在我看来,某种类型的库不兼容,但我很确定Tango Core和Tango Java API都是最新版本,都是昨天更新的。我错过了什么?
以下是该应用程序的所有代码:
package com.threedvideo.threedvideograbber;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.google.atap.tangoservice.Tango;
import com.google.atap.tangoservice.TangoCameraIntrinsics;
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.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;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private Tango tango;
private TangoConfig tangoConfig;
private TangoCameraPreview tangoCameraPreview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onStart() {
super.onStart();
tango = new Tango(MainActivity.this, new Runnable() {
@Override
public void run() {
synchronized (MainActivity.this) {
try {
tangoConfig = setupTangoConfig(tango);
tango.connect(tangoConfig);
tangoCameraPreview = (TangoCameraPreview) findViewById(R.id.tango_camera_preview);
tangoCameraPreview.connectToTangoCamera(tango, TangoCameraIntrinsics.TANGO_CAMERA_COLOR);
startupTango();
} catch (TangoOutOfDateException e) {
Log.e(TAG, "Tango service out of date", e);
} catch (TangoErrorException e) {
Log.e(TAG, "Tango service error", e);
} catch (TangoInvalidException e) {
Log.e(TAG, "Tango invalid exception", e);
}
}
}
});
}
@Override
protected void onPause() {
super.onPause();
synchronized (MainActivity.this) {
tangoCameraPreview.disconnectFromTangoCamera();
tango.disconnect();
}
}
private TangoConfig setupTangoConfig(Tango t) {
TangoConfig config = t.getConfig(TangoConfig.CONFIG_TYPE_DEFAULT);
config.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_COLORCAMERA, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_MOTIONTRACKING, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_AUTORECOVERY, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_HIGH_RATE_POSE, true);
config.putBoolean(TangoConfig.KEY_BOOLEAN_SMOOTH_POSE, true);
return config;
}
private void startupTango() {
final ArrayList<TangoCoordinateFramePair> framePairs = new ArrayList<>();
framePairs.add(new TangoCoordinateFramePair(TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE, TangoPoseData.COORDINATE_FRAME_DEVICE));
tango.connectListener(framePairs, new Tango.OnTangoUpdateListener() {
@Override
public void onPoseAvailable(TangoPoseData tangoPoseData) {
}
@Override
public void onXyzIjAvailable(TangoXyzIjData tangoXyzIjData) {
}
@Override
public void onFrameAvailable(int cameraId) {
if (cameraId == TangoCameraIntrinsics.TANGO_CAMERA_COLOR)
tangoCameraPreview.onFrameAvailable();
}
@Override
public void onTangoEvent(TangoEvent tangoEvent) {
}
@Override
public void onPointCloudAvailable(TangoPointCloudData tangoPointCloudData) {
}
});
}
}
答案 0 :(得分:3)
查看答案here,查看相同或至少非常相似的问题。解决方案是添加
config.putInt(TangoConfig.KEY_INT_DEPTH_MODE, TangoConfig.TANGO_DEPTH_MODE_POINT_CLOUD);
到设置代码(setupTangoConfig()
)。