Open georgewsinger opened 3 years ago
Should work. camera_win.cpp is basically a template, and you can look at _osx.mm, _ios.mm for details.
Alternately you could fix godot-webcam.
Spliced some code into a compiling camera_x11.cpp
:
On startup we now get:
libv4l2 found.
Registered camera UVC Camera (046d:0825) (/dev/video0) with id 1 position 0 at index 0
/dev/video1 is no video capture device.
yet counter-intuitively also get
CameraServer get_feed_count: 0
and the same black screen. This will be completed tomorrow.
Attempting to ./simula_rr_record crashes rr: https://www.wolframcloud.com/obj/39c531e3-75aa-4354-ada1-69bba1f14a41
Makes debugging this much harder.
@KaneTW Using this OS::get_singleton()->delay_usec(10)
hack gets activate_feed()
working without gdb step throughs:
bool CameraFeedX11::activate_feed() {
// activate streaming if not already
if (!device->streaming) {
OS::get_singleton()->delay_usec(10);
if (!device->check_device()) {
return false;
}
OS::get_singleton()->delay_usec(10);
if (!device->request_buffers()) {
device->close();
return false;
}
OS::get_singleton()->delay_usec(10);
if (!device->start_streaming(this)) {
device->cleanup_buffers();
device->close();
return false;
}
};
return true;
};
Here's a demo of me using webcam mode with actual VR headset movement: https://www.youtube.com/watch?v=2z2EdsQj3Os&ab_channel=GeorgeSinger. Notice that webcam images are left-right inverted.
It's a hack though. There should be a proper solution.
O_NONBLOCK is passed to funcs->open. While maybe not a bad idea, this is definitely what's causing the issue. You need to wait for the IO to finish before using it.
Goal: Set the background
Environment
to a webcamTexture
to create the illusion the user is wearing an AR headset. It should be toggleable by a keyboard shortcut.Attempting to set the background to BG_CAMERA_FEED
The
Environment
type supportsBG_CAMERA_FEED
:However, setting it in SimulaServer.hs
Just causes the background sky to turn black.
Godot doesn't support webcams for Linux
If we inspect the number of detected cameras from godot via CameraServer
...we just get "0", since it turns out that Godot doesn't even support webcams for Windows, let alone Linux. You can tell this also by file inspection:
E.g. there's no
camera_x11.*
here. So maybe we should make one?godot-webcam doesn't work out of the box
There's godot-webcam, which I got to compile but which doesn't actually get webcam textures to show:
Glimmer of hope: running this demo does get my webcam's green light to turn on.
The CameraFeed machinery seems to already be in Godot, even though camera detection/texture grabbing isn't working
I think our preferred approach should be working with pre-existing
CameraFeed
machinery within Godot, since the steps are already in place for it to render webcam textures (even though webcams aren't working). E.g. taking a look atRasterizerSceneGLES3::render_scene()
from SimulaVR/godot:If I'm right here, this means we should implement our own
.submodules/godot/modules/camera/camera_x11.cpp
(probably by borrowing some snippets fromgodot-webcam
). @kanetw thoughts?