AndroidTfLiteCameraX
AndroidTfLiteCameraX copied to clipboard
val cannot be reassigned
In
preview.setOnPreviewOutputUpdateListener {
textureView.surfaceTexture = it.surfaceTexture
updateTransform()
}
There is now an error in the textureView,surfaceTexture being updated, that the val cannot be reassigned. That line can be replaced with:
textureView.setSurfaceTexture(it.surfaceTexture)
(https://stackoverflow.com/questions/63184908/val-cannot-be-reassigned-in-android-buildtool-30-0-1)
However, while the app compiles, nothing is shown of the preview.
The answer seems to be to replace the listener as follows.
preview.setOnPreviewOutputUpdateListener {
val parent = textureView.parent as ViewGroup
parent.removeView(textureView)
textureView.setSurfaceTexture(it.surfaceTexture)
parent.addView(textureView, 0)
updateTransform()
}
And it works fine.