I am try to take a picture with an Android smartphone by using the camerax libary from Android.
I am following their tutorial to capture images.
First I need to initalize the ImageCapturer:
ImageCapture imageCapture =
new ImageCapture.Builder()
.setTargetRotation(view.getDisplay().getRotation())
.build();
cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, imageCapture, imageAnalysis, preview);
The Problem is I a error message and can't execute the code:
ImageCapture imageCapture = new ImageCapture.Builder().setTargetRotation(view.getDisplay().getRotation()).build();
^
symbol: class Builder
I included the dependencies for camerax in the gradle file:
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'
}
I don't know why it doesn't recognize the .builderI
. I hope someone can help me ^^
You're using the alpha06 version of the camerax core artifact, building a use case using the use case's builder was introduced in version07 of camerax core. For alpha06, you had to write:
PreviewConfig previewConfig = new PreviewConfig.Builder().build();
Preview preview = new Preview(previewConfig);
With more recent versions (starting from alpha07), you use the use case's builder to initialize use cases.
Preview preview = new Preview.Builder().build();
FYI, the documentation you're using is using the beta01 version of camerax core, you might want to update to that instead of using alpha06.