godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.12k stars 20.2k forks source link

Cannot access CameraTexture by get_data() #51830

Open cyberpsyche opened 3 years ago

cyberpsyche commented 3 years ago

Godot version

3.3.2 stable

System information

Mac OSX 10.15.7

Issue description

I want re-process the frames captured by webcam. I could setup a Sprite and render the webcam stream on it via a series of shader settings. But when I try to get the texture from the Sprite , it failed.

In the debugging window I could see there is a valid CameraTexture , but the img(:Image) created from the CameraTexture by get_data() is 'null'. Use the same code to process textures other than CameraTexture is always OK.

So I think maybe it is related to the CameraServer / CameraTexture specially. But the question is, how to get the textures or images from webcam stream to re-process on purpose in Godot ?

Is there anyone can help? Thanks very much !

Steps to reproduce

func webcam_frame_process(): var img :Image print($WebCamSprite.texture.get_size()) # It is OK. img = $WebCamSprite.texture.get_data() # the var img is null

Minimal reproduction project

No response

tavurth commented 2 years ago

You can see my repository which has a working example

https://github.com/tavurth/godot-camera

meko3 commented 1 year ago

I have the same problem in v4.0.beta1.official.20d667284. OS is macOS Monterey (Apple M1)

Do you have any plans to implement CameraTexture.get_data()?

tavurth commented 1 year ago

Why the downvote @meko3?

Perhaps you could try Godot 3.x instead of Beta 4?

Camera support is not well documented nor supported in Godot at this point. However if you do find a bug with your M1 mac it would be nice to report it with a bit more detail.

meko3 commented 1 year ago

This example dosen't use texture data, so this example can`t resolve this issue. And this issue isn't listed in 4 roadmap.

I'll try it with 3.x.

meko3 commented 1 year ago

I tried Godot 3.5. https://github.com/meko3/godot-camera

CameraTexture.get_data() returned [Object:null].