首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java,Android,camerax编程。错误:找不到符号。符号:类生成器

Java,Android,camerax编程。错误:找不到符号。符号:类生成器
EN

Stack Overflow用户
提问于 2020-03-23 20:33:04
回答 1查看 1.2K关注 0票数 0

我正试着用安卓手机上的照像机 libary来拍照。

我在跟踪他们的获取图像的教程。首先,我需要使ImageCapturer无效:

代码语言:javascript
复制
ImageCapture imageCapture =
new ImageCapture.Builder()
    .setTargetRotation(view.getDisplay().getRotation())
    .build();

cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, imageCapture, imageAnalysis, preview);

问题是,我是一个错误消息,无法执行代码:

代码语言:javascript
复制
    ImageCapture imageCapture = new ImageCapture.Builder().setTargetRotation(view.getDisplay().getRotation()).build();
                                                ^
  symbol:   class Builder

我在gradle文件中包含了camerax的依赖项:

代码语言:javascript
复制
apply plugin: 'com.android.application'

repositories {
    jcenter()
}

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    compileSdkVersion 28
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "org.pytorch.digitrecognizer"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            debuggable true
        }
    }
}

dependencies {
    def camerax_version = '1.0.0-alpha06'
    implementation "androidx.camera:camera-core:${camerax_version}"
    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'org.pytorch:pytorch_android:1.4.0'
    implementation 'org.pytorch:pytorch_android_torchvision:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

我不知道为什么它不承认.builderI。我希望有人能帮我

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-23 21:51:25

您正在使用camerax核心工件的alpha06版本,使用用例的构建器构建用例是在camerax核心的version07中引入的。对于alpha06,您必须编写:

代码语言:javascript
复制
PreviewConfig previewConfig = new PreviewConfig.Builder().build();
Preview preview = new Preview(previewConfig);

对于更新的版本(从alpha07开始),您可以使用用例的构建器来初始化用例。

代码语言:javascript
复制
Preview preview = new Preview.Builder().build();

FYI,您使用的文档是使用beta01版本的camerax核心,您可能想要更新到这个版本,而不是使用alpha06。

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

https://stackoverflow.com/questions/60821146

复制
相关文章

相似问题

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