3 回答
TA贡献1802条经验 获得超4个赞
Android CameraX 扩展仅存在于版本中:“1.0.0-alpha01”。
降级相机版本://Camera Jetpack Library
def camerax_version = "1.0.0-alpha01"
implementation "androidx.camera:camera-core:$camerax_version"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-extensions:$camerax_version"
TA贡献1772条经验 获得超6个赞
我刚刚注意到编辑您的问题并在此处查看您显示的代码示例是Java,但您将Kotlin作为标识符。确保您使用的是正确的语言。这可能是问题所在。
这是Android 开发者文档中的Kotlin示例:
import androidx.camera.extensions.BokehExtender
fun onCreate() {
// Create a Builder same as in normal workflow.
val builder = ImageCaptureConfig.Builder()
// Create a Extender object which can be used to apply extension
// configurations.
val bokehImageCapture = BokehImageCaptureExtender.create(builder)
// Query if extension is available (optional).
if (bokehImageCapture.isExtensionAvailable()) {
// Enable the extension if available.
bokehImageCapture.enableExtension()
}
// Finish constructing configuration with the same flow as when not using
// extensions.
val config = builder.build()
val useCase = ImageCapture(config)
CameraX.bindToLifecycle(this as LifecycleOwner, useCase)
}
这是Android 开发者文档中的Java示例:
import androidx.camera.extensions.BokehExtender;
void onCreate() {
// Create a Builder same as in normal workflow.
ImageCaptureConfig.Builder builder = new ImageCaptureConfig.Builder();
// Create a Extender object which can be used to apply extension
// configurations.
BokehImageCaptureExtender bokehImageCapture = new
BokehImageCaptureExtender(builder);
// Query if extension is available (optional).
if (bokehImageCapture.isExtensionAvailable()) {
// Enable the extension if available.
bokehImageCapture.enableExtension();
}
// Finish constructing configuration with the same flow as when not using
// extensions.
ImageCaptureConfig config = builder.build();
ImageCapture useCase = new ImageCapture(config);
CameraX.bindToLifecycle((LifecycleOwner)this, useCase);
}
TA贡献1921条经验 获得超9个赞
扩展在 google maven 上仍然不可用 https://dl.google.com/dl/android/maven2/index.html
请参阅此线程, https://stackoverflow.com/a/57177147/11861734
添加回答
举报