首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ARCore从URL生成3D对象并对图像进行增强

ARCore从URL生成3D对象并对图像进行增强
EN

Stack Overflow用户
提问于 2019-06-23 16:18:49
回答 1查看 3.3K关注 0票数 3

我在使用以下代码从URL生成3D对象时遇到问题,它给了我一个错误,我不确定它是什么。如果有人能指出代码的错误所在,那就太棒了

我关注了谷歌的教程:https://developers.google.com/ar/develop/java/sceneform/create-renderables。但由于语法错误,必须进行一些修改。

(1)下面的代码用于从URL - ASSET_URL生成3D对象(我已经测试了这个URL )。

代码语言:javascript
复制
    private AugmentedImage image;
    private CompletableFuture<ModelRenderable> modelRenderable;

        modelRenderable =
                ModelRenderable.builder()
                .setSource(context, RenderableSource.builder().setSource(
                        context,
                        Uri.parse(ASSET_URL),
                        RenderableSource.SourceType.GLTF2)
                        .setScale(0.5f)  // Scale the original model to 50%.
                        .setRecenterMode(RenderableSource.RecenterMode.ROOT)
                        .build())
                .setRegistryId(ASSET_URL)
                .build();

(2)以下代码用于将3D对象放置在图像上:

代码语言:javascript
复制
        if(!modelRenderable.isDone()){
            CompletableFuture.allOf(modelRenderable)
                    .thenAccept((Void aVoid) -> setImage(image))
                    .exceptionally(
                            throwable -> {
                                Log.e(TAG, "Exception loading", throwable);
                                return null;
                            }
                    );
            return;
        }

(3)以下代码(我从sceneform示例augmentedImage中修改)从静态本地资源生成3D对象,这与代码(2)一起工作

代码语言:javascript
复制
//        modelRenderable = ModelRenderable.builder()
//                .setSource(context,Uri.parse("SubstanceMiku.sfb"))
//                .build();

我得到了一个错误

代码语言:javascript
复制
E/Filament: Panic
    in filament::Material *filament::Material::Builder::build(filament::Engine &):85
    reason: Material version mismatch. Expected 2 but received 1.
A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 16333 (tapp.cloudimage), pid 16333 (tapp.cloudimage)
I/native: tracking.cc:3027 no history. confidence : 1.0
I/native: tracking.cc:3027 no history. confidence : 1.0
I/native: motion_analysis_calculator.cc:611 Analyzed frame 101
Application terminated.
EN

回答 1

Stack Overflow用户

发布于 2020-03-06 03:08:48

我有一个类似的问题,经过一些调试和搜索,它似乎与scenefrom plugin类路径有关。

如果您转到项目级别的评分构建文件,并将场景表单插件类路径更新为最新版本,请同步并重试,这为我消除了错误。

代码语言:javascript
复制
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.61'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.ar.sceneform:plugin:1.15.0' // <-- *THIS LINE*

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

顺便说一句,调试很棘手,可能是因为像ModelRenderable.builder这样的一些功能利用了不会崩溃的较低层,并像其他一些安卓层一样干净地抛出异常。即使崩溃是从builder中的.build生成的,通过一步一步地注释出代码来确认,“exceptionally”子句也没有被调用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56722175

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档