我正在使用ar core执行ar应用程序,但我的应用程序因以下错误而崩溃:
E/ACameraMetadata: getConstEntry: cannot find metadata tag 65578
I/native: I0709 15:03:43.735069 11118 distribute.cc:79] No keypoints to prune.
W/native: W0709 15:03:43.735633 11140 feature_matcher_and_filter_utils.cc:260] INVALID_ARGUMENT: integration window start at 0 Use identity R.
E/native: E0709 15:03:43.752435 10833 session.cc:2466] Invalid ray produced by view data!
E/native: E0709 15:03:43.786521 10833 session.cc:2466] Invalid ray produced by view data!
I/native: I0709 15:03:43.813694 11118 distribute.cc:79] No keypoints to prune.
E/native: E0709 15:03:43.820315 10833 session.cc:2466] Invalid ray produced by view data!
E/native: E0709 15:03:43.853287 10833 session.cc:2466] Invalid ray produced by view data!
E/native: E0709 15:03:43.885599 10833 session.cc:2466] Invalid ray produced by view data!
I/native: I0709 15:03:43.898235 11118 distribute.cc:79] No keypoints to prune.
E/native: E0709 15:03:43.918849 10833 session.cc:2466] Invalid ray produced by view data!
E/native: E0709 15:03:43.952234 10833 session.cc:2466] Invalid ray produced by view data!
E/native: E0709 15:03:43.985354 10833 session.cc:2466] Invalid ray produced by view data!
它在无限循环中这样做,但它不显示任何内容。我认为这样做是因为它无法到达摄像机,也没有任何关键点,因为它看不到这些。
我的代码是:
public class realidadAumentada extends AppCompatActivity {
ArFragment arFragment;
ModelRenderable astroRenderable;
private static final double MIN_OPENGL_VERSION = 3.0;
private String url = "https://modelviewer.dev/shared-assets/models/Astronaut.glb";
@Override
@SuppressWarnings({"AndroidApiChecker", "FutureReturnValueIgnored"})
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_realidad_aumentada);
if (!checkIsSupportedDeviceOrFinish(realidadAumentada.this)) {
return;
}
setContentView(R.layout.activity_main);
arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.fragmentAR);
setUpModel();
arFragment.setOnTapArPlaneListener(new BaseArFragment.OnTapArPlaneListener() {
@Override
public void onTapPlane(HitResult hitResult, Plane plane, MotionEvent motionEvent) {
Anchor anchor = hitResult.createAnchor();
AnchorNode anchorNode = new AnchorNode(anchor);
anchorNode.setParent(arFragment.getArSceneView().getScene());
createModel(anchorNode);
}
});
}
//Método para crear el modelo
public void createModel(AnchorNode anchorNode){
TransformableNode node = new TransformableNode(arFragment.getTransformationSystem());
node.setParent(anchorNode);
node.setRenderable(astroRenderable);
node.select();
}
//Método para construir el modelo
public void setUpModel() {
ModelRenderable.builder()
.setSource(this,
RenderableSource.builder().setSource(
this,
Uri.parse(url),
RenderableSource.SourceType.GLB)
.setScale(0.75f)
.setRecenterMode(RenderableSource.RecenterMode.ROOT)
.build())
.setRegistryId(url)
.build()
.thenAccept(renderable -> astroRenderable = renderable)
.exceptionally(throwable -> {
Toast toast =
Toast.makeText(realidadAumentada.this, "Unable to load andy renderable", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return null;
});
}
//Método para ver si el dispositivo es compatible
public static boolean checkIsSupportedDeviceOrFinish(final Activity activity) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
//Aparece una ventana que dice que no es compatible
Log.e("ERROR", "Sceneform requires Android N or later");
Toast.makeText(activity, "Sceneform requires Android N or later", Toast.LENGTH_LONG).show();
activity.finish();
return false;
}
String openGlVersionString =
((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE))
.getDeviceConfigurationInfo()
.getGlEsVersion();
if (Double.parseDouble(openGlVersionString) < MIN_OPENGL_VERSION) {
Log.e("ERROR", "Sceneform requires OpenGL ES 3.0 later");
Toast.makeText(activity, "Sceneform requires OpenGL ES 3.0 or later", Toast.LENGTH_LONG)
.show();
activity.finish();
return false;
}
return true;
}
}
此外,我的舱单中有:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.ar" android:required="true"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="true" />
我相信我没有忘记舱单上的任何东西。
谢谢!:)
暂无答案!
目前还没有任何答案,快来回答吧!