AndroidTfLiteCameraX icon indicating copy to clipboard operation
AndroidTfLiteCameraX copied to clipboard

val cannot be reassigned

Open karencfisher opened this issue 2 years ago • 0 comments

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.

karencfisher avatar Sep 30 '22 03:09 karencfisher