Godot Version
4.2.2
Question
If you keep sending emitSignal at 30 frames, the app will stop. The same is true for slower. You don’t need to create a function in Kodo Engine to receive data to cause the app to stop.
If I comment out this emitSignal, the app doesn’t stop.
Is there any way to replace this part?
I want to get real-time data from Android and render or process it in Godot Engine. I want to know if it’s possible!
val imageAnalyzer = ImageAnalysis.Builder()
.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.setTargetRotation(Surface.ROTATION_0)
.build()
.also {
it.setAnalyzer(cameraExecutor, object : ImageAnalysis.Analyzer {
private var lastEmitTime = 0L
private val EMIT_INTERVAL = 33
override fun analyze(image: ImageProxy) {
val currentTime = System.currentTimeMillis()
if (currentTime - lastEmitTime >= EMIT_INTERVAL) {
val width = image.width
val height = image.height
val buffer = image.planes[0].buffer
val data = ByteArray(buffer.remaining())
buffer.get(data)
emitSignal("updateData", data, width, height)
lastEmitTime = currentTime
}
image.close()
}
})
}