【发布时间】:2019-08-13 18:26:33
【问题描述】:
我正在尝试构建基于 CameraX 的相机应用,并希望为相机预览启用散景(模糊)效果。这可以通过 CameraX 扩展来完成,但是如何启用它们呢?
我在Android Developer Docs 阅读了有关供应商扩展的文章。我尝试重用他们的方法,但示例中显示的类不包含在 CameraX alpha-02
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);
}
我预计 BokehImageCaptureExtender 将被导入,但看起来它仍然没有提供。整个包裹androidx.camera.extensions 不见了。
这些类可以在官方AndroidX git repository 找到,但如果不导入完整的 AndroidX 项目就很难设置它。
【问题讨论】:
标签: java android android-camerax