Kinect v2 camera feed in godot.

Godot Version

godot 4.5

Question

I am trying to get the depth camera feed in to Godot for that I have now the depth images in a v4l2 loopback device in the format 24-bit BGR 8-8-8 but I get this output where the depth is overlapping itself like in the picture below:

When I read out the loopback device with ffplay I get the expected image:

So how could I get it to work I have included the gd script and shader I am using below:

this is the gd script.

extends Sprite2D

@export var camera_name: String = “Depth-Loopback”#“Video-Loopback”var camera: CameraFeed

func wait(seconds: float) → void:await get_tree().create_timer(seconds).timeout

Called when the node enters the scene tree for the first time.

func _ready():CameraServer.monitoring_feeds = truevar test=0while test <10:print(“cameras:”)for feed in CameraServer.feeds():var cam_name = feed.get_name()print(cam_name)# if camera_name is left empty, use the first available camera
	if camera == null and (camera_name == "" or cam_name == camera_name):
			camera = feed
			print(feed.get_datatype())
			print("formats:",feed.get_formats())
			print(camera.set_format(0,{"format": "24-bit BGR 8-8-8"}))#{"format":"grayscale"}))#{"format": "24-bit BGR 8-8-8"})
			#camera.set_external(512,424)
			print(camera.get_id())
			test = 11
		test+=1
print("cameras:")
for feed in CameraServer.feeds():
	var cam_name = feed.get_name()
	print(cam_name)
	# if camera_name is left empty, use the first available camera
	if camera == null and (camera_name == "" or cam_name == camera_name):
		camera = feed
		print(feed.get_datatype())
		
		#camera.set_format(0,("format": "24-bit BGR 8-8-8"))

if camera == null:
	print("no matching camera")
	return
	
print("using camera ", camera, " (", camera.get_name(), ")")

camera.feed_is_active = true

var cam_tex_y = material.get_shader_parameter("camera_rgb")
#var cam_tex_CbCr = material.get_shader_parameter("camera_CbCr")

cam_tex_y.camera_feed_id = camera.get_id()
#cam_tex_CbCr.camera_feed_id = camera.get_id()

material.set_shader_parameter("camera_rgb", cam_tex_y)
#material.set_shader_parameter("camera_CbCr", cam_tex_CbCr)
and this is the shader code
shader_type canvas_item;

uniform sampler2D camera_rgb;
uniform sampler2D camera_CbCr;


uniform bool flip_horz = false;uniform bool flip_vert = false;

void vertex() {if (flip_horz) {UV.x = 1.0 - UV.x;}if (flip_vert) {UV.y = 1.0 - UV.y;}}

void fragment() {
vec3 color;color.rgb = texture(camera_rgb, UV).rgb;//color.gb = texture(camera_CbCr, UV).rg - vec2(0.5, 0.5);
// YCbCr -> SRGB conversion
// Using BT.709 which is the standard for HDTV




COLOR = vec4(color.b,color.g,color.r, 1.0);
}