I want to display webcam without distortion

Godot Version

4.4.1

Question

I was able to display webcam on macOS by referring to the following source. However, I cannot get the aspect ratio of the camera image. Therefore, if I don’t know the camera’s aspect ratio in advance, the image becomes distorted. Is there a way to adjust the image size according to the camera device?

I was able to get the camera aspect ratio with the following code.

var size = Vector2.ZERO
while true:
	size = cam_tex_y.get_size()
	if size.x > 0 and size.y > 0:
		break
	await get_tree().process_frame
var aspect = size.y / size.x
self.scale.y = self.scale.x * aspect
1 Like