UltraStar-Deluxe / USDX

The free and open source karaoke singing game UltraStar Deluxe, inspired by Sony SingStar™
https://usdx.eu
GNU General Public License v2.0
832 stars 160 forks source link

Webcam not working in linux #476

Closed batrique closed 5 years ago

batrique commented 5 years ago

The webcam feature does not seem to work in Linux. When I try to use the build-in webcam on my laptop the game says "No Webcam Found!". I also tried with a USB webcam and got the same result. The usb webcam is detected by the game and can be used as a microphone. The two webcams that I tried work in other programs without issue. Maybe it is a problem with OpenCV?

Capture d’écran de 2019-08-26 23-56-06

Error.log

s09bQ5 commented 5 years ago

Please try again with current master. The symbols for accessing cameras have been moved to a different OpenCV module.

In my Pop!_OS VM USDX can now capture frames, but fails to create an OpenGL texture (SIGSEGV in swrast_dri that is gracefully caught and hidden by Free Pascal). I hope it works on real hardware.

s09bQ5 commented 5 years ago

No need to try again. It won't work. The crash in swrast_dri happens because the IplImage structure is no longer packed and needs 4 bytes padding between imageSize and imageData on 64 bit architectures. I need to work out how to detect this. Maybe we should switch to cvGetRawData.

s09bQ5 commented 5 years ago

@basisbit, camera support is something inherited from World Party, isn't it? So we don't know who wrote those OpenCV units and we don't know why that person chose to mark the IplImage record as packed?

Am I right that nobody has ever built USDX for 64 bit Windows and reported that cameras work? In that case I would simply remove the packed word from that record.

basisbit commented 5 years ago

afaik, camera support initially started as a patch file submitted but not merged to usdx on sourceforge, then was integrated an further implemented by the usdx world party fork. When these forks were merged, I only fixed the most basic bugs including memory leaks all over the place and did some refactoring and catching plus handling errors. Builds targeting Winndows so far are always 32bit/x86 builds for compatiblity reasons.

batrique commented 5 years ago

Is the bug fixed now? The webcam feature does not work when I try to start the game with WINE (I do not know if it helps ...). I tried under Windows and the webcam works. I have never been able to build the game for 64-bit Windows (I always get errors, but maybe it's because I'm stupid). But 32-bit Windows works fine.

batrique commented 5 years ago

So I just updated the game and now the led of my webcam turn on but the rest don't work... Capture d’écran de 2019-08-28 12-47-34

Also when starting the game from the debuger in lazarus I get this error: "The ultrastardx project has raised an exceptional class "External : SIG32". In file: "..sysdeps/unix/sysv/linux/poll.c" at line 29."

Capture d’écran de 2019-08-28 12-49-14

and this: "The file "/build/glibc-KRRWS/sysdeps/unix/sysv/linux/poll.c" was not found. Do you want to search manually?." Capture d’écran de 2019-08-28 12-50-51 Error.log

s09bQ5 commented 5 years ago

Don't be so impatient. I was at work earning money for 10 hours and will now continue fixing your problem. You could have saved yourself all that work taking pictures by comparing the time of the head commit on the master branch with my messages in this discussion.

s09bQ5 commented 5 years ago

Should be fixed now

s09bQ5 commented 5 years ago

@batrique, did you already have time to test it? Can we close this issue?

luto commented 5 years ago

@s09bQ5 the current master lets me choose between webcam 1 and 0, both of which yield "No webcam found!" when I click "Enable Preview". There is no crash, system message, freeze or console output in that case.

Sorry that I cannot be of more help. I'm not a USDX user and just came across this issue randomly, while looking at another one ;)

batrique commented 5 years ago

@s09bQ5 It is working! Sorry if I looked impatient. It was not my intention. I wanted to provide as much information as possible to help you. Thank you for your awesome work!

s09bQ5 commented 5 years ago

@luto, there is only one error message for all problems that could prevent us from accessing the camera. Do you have the OpenCV development package installed? Is your user allowed to open the /dev/video* devices? USDX will always let you to select between webcam 0 and 1, even if there are no or more cameras connected.

With OpenCV there is no way to list cameras without actually trying to open each of them by index. And even if we open a camera, we are not told its name or maximum resolution. All we are told is the lower level interface like V4L2 or DirectShow.

Oh great, I just noticed that OpenCV 4 drops the C API. We will have to write a C++ wrapper like we did for ProjectM.

s09bQ5 commented 5 years ago

Since batrique's problem is resolved, I have created a new issue for OpenCV 4. But if luto is having problems with OpenCV 3 we can of course continue to discuss it here.

luto commented 5 years ago

If batrique's setup works fine now, we can close this.