当前位置: 首页 > 知识库问答 >
问题:

如何在ARCore Android中禁用表面检测

孔飞翔
2023-03-14

我正在工作的一个项目和面临一个问题与ARCORE。我在我的项目中使用了ARCore定位,我使用纬度和经度来设置对象的位置。但当我在设备中看到它时,对象位置在AR中是不同的。

CompletableFuture<ViewRenderable> exampleLayout = ViewRenderable.builder()
                    .setView(this, R.layout.example_layout)
                    .build();

    // When you build a Renderable, Sceneform loads its resources in the background while returning
    // a CompletableFuture. Call thenAccept(), handle(), or check isDone() before calling get().
    CompletableFuture<ModelRenderable> andy = ModelRenderable.builder()
            .setSource(this, R.raw.andy)
            .build();


    CompletableFuture.allOf(
            exampleLayout,
            andy)
            .handle(
                    (notUsed, throwable) -> {
                        // When you build a Renderable, Sceneform loads its resources in the background while
                        // returning a CompletableFuture. Call handle(), thenAccept(), or check isDone()
                        // before calling get().

                        if (throwable != null) {
                            DemoUtils.displayError(this, "Unable to load renderables", throwable);
                            return null;
                        }

                        try {
                            exampleLayoutRenderable = exampleLayout.get();
                            andyRenderable = andy.get();
                            hasFinishedLoading = true;

                        } catch (InterruptedException | ExecutionException ex) {
                            DemoUtils.displayError(this, "Unable to load renderables", ex);
                        }

                        return null;
                    });

    // Set an update listener on the Scene that will hide the loading message once a Plane is
    // detected.
    arSceneView
            .getScene()
            .setOnUpdateListener(
                    frameTime -> {
                        if (!hasFinishedLoading) {
                            return;
                        }

                        if (locationScene == null) {
                            // If our locationScene object hasn't been setup yet, this is a good time to do it
                            // We know that here, the AR components have been initiated.
                            locationScene = new LocationScene(this, this, arSceneView);

                            // Now lets create our location markers.
                            // First, a layout
                            LocationMarker layoutLocationMarker = new LocationMarker(
                                    77.398151,
                                    28.540926,
                                    getExampleView()
                            );

                            // An example "onRender" event, called every frame
                            // Updates the layout with the markers distance
                            layoutLocationMarker.setRenderEvent(new LocationNodeRender() {
                                @SuppressLint("SetTextI18n")
                                @Override
                                public void render(LocationNode node) {
                                    View eView = exampleLayoutRenderable.getView();
                                    TextView distanceTextView = eView.findViewById(R.id.textView2);
                                    distanceTextView.setText(node.getDistance() + "M");
                                }
                            });
                            // Adding the marker
                            locationScene.mLocationMarkers.add(layoutLocationMarker);

                            // Adding a simple location marker of a 3D model
                            locationScene.mLocationMarkers.add(
                                    new LocationMarker(
                                            77.398151,
                                            28.540926,
                                            getAndy()));
                        }

                        Frame frame = arSceneView.getArFrame();
                        if (frame == null) {
                            return;
                        }

                        if (frame.getCamera().getTrackingState() != TrackingState.TRACKING) {
                            return;
                        }

                        if (locationScene != null) {
                            locationScene.processFrame(frame);
                        }

                        if (loadingMessageSnackbar != null) {
                            for (Plane plane : frame.getUpdatedTrackables(Plane.class)) {
                                if (plane.getTrackingState() == TrackingState.TRACKING) {
                                    hideLoadingMessage();
                                }
                            }
                        }
                    });


    // Lastly request CAMERA & fine location permission which is required by ARCore-Location.
    ARLocationPermissionHelper.requestPermission(this);

它的主要问题是它检测表面和放置图像根据它,如果有任何可能禁用表面检测,那么它的工作是完美的。

共有1个答案

何长恨
2023-03-14

使用EnablePlaneFinding=false修改会话配置,然后禁用并重新启用arCoreSession。这将禁止寻找飞机,但将保持现有的飞机,因为他们现在。

如果不想禁用会话,可以在不禁用会话的情况下对会话强制执行OnEnable()调用:

 var session = GameObject.Find("ARCore Device").GetComponent<ARCoreSession>(); 
session.SessionConfig.EnablePlaneFinding = false; session.OnEnable();
 类似资料:
  • 我正在将一个服务从Flask迁移到FastAPI,并使用Pydantic模型来生成文档。但是,我对模式检查有点不确定。我担心会有一些意想不到的数据(如不同的字段格式),它会返回一个错误。 在Pydantic文档中,有一些方法可以在不检查模式的情况下创建模型:https://Pydantic-docs . help manual . io/usage/models/# creating-models

  • 问题内容: 我正在使用urllib.request.urlretrieve将文件下载到本地。 它引发错误: ssl.CertificateError了未处理由用户代码消息:主机名“foo.net”不匹配的“a248.e.akamai.net”,“要么 _.akamaihd.net”,“ .akamaihd-staging.net”,’ 。 akamaized.net”,“_ .akamaized-

  • 我有一个maven项目,其中jmockit 1.18用于嘲笑,surefire用于运行测试套件,Jacoco用于测量代码覆盖率。 当我尝试将jmockit升级到1.45版时,它在初始化测试套件运行程序VM时出错。但是,当javaagent作为argline参数显式传递时,测试就会执行。 有人能告诉我是否有办法禁用jmockit检测或代理初始化吗?

  • 我不知道如何使Tkinter变灰。 我试着使用,但它不起作用,我得到一个错误,说 _特金特。TclError:错误选项“-enable”:必须是-column、-columnspan、-in、-ipadx、-ipady、-padx、-pady、-row、-rowspan或-sticky 如何临时禁用?

  • 我在Android上与ARCore一起使用Sceneform,无法通过提供的文档清楚地理解这些概念。我正试图从github修改现有的HelloSceneform应用程序,并尝试创建一个应用程序,在这个应用程序中,一旦启动,用户就会直接在他/她的前面看到一个3D对象。这和我发现的很相似https://github.com/google-ar/arcore-unity-sdk/issues/144,但

  • 问题: 在我的清单中,我的应用程序字的背景是黄色的,当我做Alt+Enter时,它给了我上面的选项,我点击禁用检查只是为了检查它,但是当我做Alt+Enter时,但是在做了Alt+Enter之后,我没有得到任何使它启用的选项? 点击“禁用检查”后,我没有得到“启用检查”的任何选项,有没有办法重新启用?