gpt4 book ai didi

textures - 更新和发布 : GLConsumer is not attached to an OpenGL ES context

转载 作者:行者123 更新时间:2023-12-05 02:59:25 26 4
gpt4 key购买 nike

我不断收到此错误。当我尝试使用 CameraX 库打开相机时。相同的代码在比 pie 小的其他设备上运行。但没有在馅饼上运行(相机没有显示)

这是我的代码:我也在我的项目中使用生命数据,这会导致任何问题吗?

  val previewConfig = PreviewConfig.Builder()
.setLensFacing(CameraX.LensFacing.BACK)
.build()
val preview = Preview(previewConfig)
preview.setOnPreviewOutputUpdateListener { previewOutput ->
_textureView.surfaceTexture = previewOutput.surfaceTexture
}
val imageAnalysisConfig = ImageAnalysisConfig.Builder()
.build()
val imageAnalysis = ImageAnalysis(imageAnalysisConfig)
val qrCodeAnalyzer = QRCodeAnalyzer { qrCodes ->
qrCodes.forEach {
Log.d("MainActivity", "QR Code detected: `${it.rawValue}.")`
val intent = intent.putExtra("RESULT",it.rawValue)
setResult(Activity.RESULT_OK,intent)
finish()
}
}

imageAnalysis.analyzer = qrCodeAnalyzer

// We need to bind preview and imageAnalysis use cases
CameraX.bindToLifecycle(this as LifecycleOwner , preview, imageAnalysis)

日志:查看我得到的日志

 E/GLConsumer: [SurfaceTexture-0-3196-1] updateAndRelease: GLConsumer is not attached to an OpenGL ES context
E/GLConsumer: [SurfaceTexture-0-3196-1] updateAndRelease: GLConsumer is not attached to an OpenGL ES context
E/GLConsumer: [SurfaceTexture-0-3196-1] updateAndRelease: GLConsumer is not attached to an OpenGL ES context
E/GLConsumer: [SurfaceTexture-0-3196-1] updateAndRelease: GLConsumer is not attached to an OpenGL ES context

最佳答案

我刚刚遇到了类似的问题。我按照此处的建议通过删除并重新添加 SurfaceTexture 来解决它 https://stackoverflow.com/a/56121351/11977949 .

您应该将 setOnPreviewOutputUpdateListener 更改为:

preview.setOnPreviewOutputUpdateListener {
val parent = viewFinder.parent as ViewGroup
parent.removeView(viewFinder)
viewFinder.surfaceTexture = it.surfaceTexture
parent.addView(viewFinder, 0)
updateTransform()
}

更多详情,查看official sample .

关于textures - 更新和发布 : GLConsumer is not attached to an OpenGL ES context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57922537/

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