亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何啟用 Android CameraX 供應商擴展?

如何啟用 Android CameraX 供應商擴展?

侃侃爾雅 2023-02-23 10:33:20
我正在嘗試構建基于 CameraX 的相機應用程序,并希望為相機預覽啟用散景(模糊)效果。這可能是由 CameraX 擴展來完成的,但是如何啟用它們呢?我已經在Android Developer Docs閱讀了有關供應商擴展的文章。我嘗試重用他們的方法,但示例中顯示的類未包含在 CameraX 中alpha-02import 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 存儲庫中找到,但是如果不導入完整的 AndroidX 項目就很難設置它。
查看完整描述

3 回答

?
慕虎7371278

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"


查看完整回答
反對 回復 2023-02-23
?
夢里花落0921

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);

}


查看完整回答
反對 回復 2023-02-23
?
郎朗坤

TA貢獻1921條經驗 獲得超9個贊

擴展在 google maven 上仍然不可用 https://dl.google.com/dl/android/maven2/index.html

請參閱此線程, https://stackoverflow.com/a/57177147/11861734


查看完整回答
反對 回復 2023-02-23
  • 3 回答
  • 0 關注
  • 182 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號