#CameraServer
29 messages · Page 1 of 1 (latest)
(The main platform I care about here is linux but it working on windows is fine too)
4.4 added camera support on Linux but I think Windows is still not supported
YO?
well that means I can make a camera based game now
just cant do a windows release for a while
ok so the picture is green and blue for some reason? the shader I took from the tutorial might be using a different system, that's my guess
uniform sampler2D camera_y;
uniform sampler2D camera_CbCr;
void fragment() {
vec3 color;
color.r = texture(camera_y, UV).r;
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.rgb = mat3(
vec3(1.00000, 1.00000, 1.00000),
vec3(0.00000, -0.18732, 1.85560),
vec3(1.57481, -0.46813, 0.00000)) *
color.rgb;
COLOR = vec4(color, 1.0);
}```
```extends Sprite2D
@export var camera_name: String = ""
var camera: CameraFeed
# Called when the node enters the scene tree for the first time.
func _ready():
print("cameras:")
for feed in CameraServer.feeds():
feed.set_format(0,{"output":"grayscale"})
var name = feed.get_name()
print(name)
# if camera_name is left empty, use the first available camera
if camera == null and (camera_name == "" or name == camera_name):
camera = feed
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_y")
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_y", cam_tex_y)
material.set_shader_parameter("camera_CbCr", cam_tex_CbCr)```
theres basically all the code
I don't know anything about camera color formats but it might just be the wrong one
I see yCbCr conversion in the shader which is one of the camera formats, but you need to check what your camera uses
YCBCR seems to be what the camera is using (I changed the one line to feed.set_format(0,{"output":"copy"}))
unless I did the dictionary wrong?
the docs are not crystal clear but that seems like a reasonable assumption
would be nice if there was some example code
oh boy I sure do hope someone with very specific knowledge in this field shows up to help while I'm asleep
Ok I'm conscious again
ok since I'm already here might as well ask is there a way to get the color of a pixel on the camera?
yeah you can call get_image() on the CameraTexture which will give you a copy of the texture's image data at that time, that can be accessed by scripts
that's an Image object which has all sorts of methods to access its data
you might have to replicate the color conversion done in the shader, if needed
Oh I just thought of a way more efficient way to do what I wanted to that would not require me to check every pixel every frame
Is there some sort of image recognition library in godot that lets you detect the position of body parts in an image? Sort of like what the game dance dash does
pretty sure there's nothing built-in, no, but maybe someone made something like that as an extension?
Yeah I was expecting that lol
I'll look around when I get home, hopefully there's a solution
I should just make evil dance dash (only works on the platforms dance dash doesn't work on [aka everything but windows lmao])
so how exactly do I get the CameraTexture? I am really confused
managed to figure that out nvm