Godot Version
4.2.2
Question
Building an Android Camera Plugin for godot
I’m getting stuck at the output!
I’m trying to figure out
I want to know if something is wrong!
I used CameraX as one of the Android libraries.
From there, I was able to convert the image analyzer to a format.rgba8888 that can be read by the GoDaddy engine, and I received it from the GoDaddy engine in the form of byte and rendered and output it directly. I adjusted the delivery rate to about 30 frames.
: at: uniform_set_create (drivers/vulkan/rendering_device_vulkan.cpp:5867)
01-27 01:21:12.856 31140 31267 E godot : USER ERROR: Parameter “uniform_set” is null.
01-27 01:21:12.856 31140 31267 E godot : at: draw_list_bind_uniform_set (drivers/vulkan/rendering_device_vulkan.cpp:7368)
01-27 01:21:12.856 31140 31267 E godot : USER ERROR: Uniforms were never supplied for set (3) at the time of drawing, which are required by the pipeline
I get this error.
I was wondering if this method itself is correct?
I tried increasing the vulkan memory, but it turns off after 5 minutes and heats up badly.
I’ve been rendering in _draw():, is there a faster and more efficient way to do this?
I’ve googled and found that using shaders has a performance advantage by passing the byte texture information directly to the GPU.
I’d love to know what’s wrong with what I’m doing and improve it!
If you end up making a plugin, I’d love to share it!
val imageAnalyzer = ImageAnalysis.Builder()
.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
.also {
it.setAnalyzer(cameraExecutor, object : ImageAnalysis.Analyzer {
private var lastEmitTime = 0L
private val EMIT_INTERVAL = 600 // 밀리초 단위
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()
}
})
}
var packed_byte_array: PackedByteArray = PackedByteArray()
var image: Image
var texture: ImageTexture
var screen_rect: Rect2
func _ready():
screen_rect=get_viewport().get_visible_rect()
var center_position = -screen_rect.size / 2
screen_rect.position = center_position
func UseCamera(data, width, height):
packed_byte_array = PackedByteArray(data)
image = Image.create(width, height, false, Image.FORMAT_RGBA8)
texture = ImageTexture.create_from_image(image)
image.set_data(width, height, false, Image.FORMAT_RGBA8, packed_byte_array)
texture.update(image)
queue_redraw()
func _draw():
if texture:
draw_set_transform(Vector2.ZERO,PI/2+PI)
draw_texture_rect( texture,screen_rect,false)