gpt4 book ai didi

Android CameraX 检索摄像机配置文件参数时出错

转载 作者:行者123 更新时间:2023-12-03 16:46:44 26 4
gpt4 key购买 nike

我正在迁移到 cameraX 并遇到异常

androidx.camera.core.InitializationException: java.lang.RuntimeException: Error retrieving camcorder profile params
错误日志指出调用时会引发此错误
            cameraProvider = cameraProviderFuture.get()
我无法在任何设备上重现此错误。
我在这里初始化相机:
private fun initCameraProvider() {
val cameraProviderFuture = ProcessCameraProvider.getInstance(this) //Error is thrown here
cameraProviderFuture.addListener(Runnable {
cameraProvider = cameraProviderFuture.get()
val metrics = DisplayMetrics().also {
previewView?.display?.getRealMetrics(it)
}
val screenAspectRatio = ImageUtils.aspectRatio(metrics.widthPixels, metrics.heightPixels)
val rotation = previewView?.display?.rotation ?: 0

preview = Preview.Builder()
.setTargetAspectRatio(screenAspectRatio)
.setTargetRotation(rotation)
.build()
analyzer = BarcodeAnalyzer(previewView, overlay) { onSuccess(it) }
val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA

imageAnalyzer = ImageAnalysis.Builder()
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.setTargetAspectRatio(screenAspectRatio)
.build()
.also {
it.setAnalyzer(cameraExecutor, analyzer)
}


val useCaseGroup = UseCaseGroup.Builder()
.addUseCase(preview)
.addUseCase(imageAnalyzer)
.build()
try {
cameraProvider?.unbindAll()
preview.setSurfaceProvider(previewView?.surfaceProvider)
camera = cameraProvider?.bindToLifecycle(this, cameraSelector, useCaseGroup)
} catch (exc: Exception) {
Log.e(TAG, "Use case binding failed", exc)
}


}, ContextCompat.getMainExecutor(this))
}

最佳答案

更新:(2021 年 3 月 24 日 - 日/月/年)
该错误已在 CameraX 1.0.0-rc04 中修复和 1.0.0-alpha23 .
只需将依赖项更新到此版本或更高版本

更新:(22/03/2021 - dd/MM/yyyy)
应该很快就会有一个新的 CameraX 版本来解决这个问题,同时您可以应用这个解决方法:

// CameraX core library
def camerax_version = '1.0.0-rc03'
implementation("androidx.camera:camera-core") {
version {
strictly "$camerax_version"
}
because "Force use 1.0.0-rc03"
}

// CameraX Camera2 extensions
implementation("androidx.camera:camera-camera2") {
version {
strictly "$camerax_version"
}
because "Force use 1.0.0-rc03"
}

// CameraX Lifecycle library
implementation("androidx.camera:camera-lifecycle") {
version {
strictly "$camerax_version"
}
because "Force use 1.0.0-rc03"
}
implementation "androidx.camera:camera-extensions:1.0.0-alpha22"
implementation 'androidx.camera:camera-view:1.0.0-alpha22'
如所述 here

目前,CameraX 中存在影响(至少)三星 S20+ 和 Galaxy Note 10+ 的错误
这里是更新的问题链接: https://issuetracker.google.com/issues/181599852

关于Android CameraX 检索摄像机配置文件参数时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66578828/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com