vignetteapp / vignette

The open source VTuber software. ❤
https://www.vignetteapp.org
Other
520 stars 33 forks source link

Unhandled error: the item HD WebCam already exists in this FluentDropdown #234

Closed Speykious closed 3 years ago

Speykious commented 3 years ago

I am getting this error when trying to run Vignette with dotnet run -p Vignette.Desktop. image OS: Arch Linux, latest kernel

Speykious commented 3 years ago

Here is the full stderr log: dotnet-run-stderr.log

Speykious commented 3 years ago

I think I found the problem. The first 2 webcam devices listed on my machine have the exact same name, which makes the program crash. image However, I only have one webcam. If I look into the output of v4l2-ctl --list-devices, what I take from it is that the same webcam is accessible through both /dev/video0 and /dev/video1. image

Speykious commented 3 years ago

Assuming 2 webcams cannot have the same name at all, my suggestion is to simply ignore duplicates.

karmek-k commented 3 years ago

I have the same issue on Manjaro Linux, my kernel's version is 5.10.68-1

[runtime] 2021-10-01 21:33:02 [error]: System.ArgumentException: The item Integrated Camera: Integrated C
[runtime] 2021-10-01 21:33:02 [error]: already exists in this FluentDropdown.

And for v4l2-ctl --list-devices:

Integrated Camera: Integrated C (usb-0000:00:10.0-1):
    /dev/video0
    /dev/video1
iojcde commented 3 years ago

I am able to run the app, but it does not seem to detect my camera. Any ideas @sr229 ?

Speykious commented 3 years ago

I am able to run the app, but it does not seem to detect my camera. Any ideas @sr229 ?

What's the exact error you're getting?

iojcde commented 3 years ago

@Speykious I'm not getting an error, it just shows nothing in the camera select dropdown. I had my USB webcam plugged in, and v4l2 detects the device.

Speykious commented 3 years ago

Are you building against the latest commit?

iojcde commented 3 years ago

Yep, I cloned the repo, and ran it from source.

Speykious commented 3 years ago

Ok... What's the output of v4l2-ctl --list-devices?

iojcde commented 3 years ago
❯ v4l2-ctl --list-devices
Dummy video device (0x0000) (platform:v4l2loopback-000):
    /dev/video0

USB2.0 PC CAMERA: USB2.0 PC CAM (usb-0000:04:00.3-2):
    /dev/video1
    /dev/video2
    /dev/media0

The dummy camera is v4l2loopback

LeNitrous commented 3 years ago

Here's the class handling the cameras on Linux if you guys plan on checking it out. https://github.com/vignetteapp/vignette/blob/master/Vignette.Camera/Platform/LinuxCameraManager.cs

Speykious commented 3 years ago

@LeNitrous check PR #235, I've made one suggestive modification to it such that it indexes friendly names

karmek-k commented 3 years ago

I tried hard-coding the name of my camera device in LinuxCameraManager.cs.

protected override IEnumerable<CameraInfo> EnumerateAllDevices()
{
    yield return new CameraInfo("/sys/class/video4linux/video0/name", "/dev/video0");
}

This particular exception seems to have gone away, but there is a different one now:

Unhandled exception. System.TypeInitializationException: The type initializer for 'Emgu.CV.Util.VectorOfInt' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'cvextern' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libcvextern: cannot open shared object file: No such file or directory

I guess that it's related to a shared library named libcvextern.so - however, an EmguCV wiki page says that it should be built from source on Linux, but I don't want to compile it right now (I can try tomorrow though, if it's needed).

Regarding the multiple camera devices issue - I suggest writing an algorithm that maps device filenames (such as /dev/camera0) to their names in the system (like Integrated Camera) and deletes keys that have duplicate values. I can try doing this, just tell me if it's necessary.

Speykious commented 3 years ago

I tried hard-coding the name of my camera device in LinuxCameraManager.cs.

protected override IEnumerable<CameraInfo> EnumerateAllDevices()
{
    yield return new CameraInfo("/sys/class/video4linux/video0/name", "/dev/video0");
}

This particular exception seems to have gone away, but there is a different one now:

Unhandled exception. System.TypeInitializationException: The type initializer for 'Emgu.CV.Util.VectorOfInt' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'cvextern' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libcvextern: cannot open shared object file: No such file or directory

I guess that it's related to a shared library named libcvextern.so - however, an EmguCV wiki page says that it should be built from source on Linux, but I don't want to compile it right now (I can try tomorrow though, if it's needed).

Regarding the multiple camera devices issue - I suggest writing an algorithm that maps device filenames (such as /dev/camera0) to their names in the system (like Integrated Camera) and deletes keys that have duplicate values. I can try doing this, just tell me if it's necessary.

Sorry to not have mentioned that in a previous issue. This is a known bug: on Linux, EmguCV places its libcvextern.so runtime under bin/Debug/net5.0/runtimes/ubuntu.20.04-x64/native/ after a dotnet build, and then claims that it cannot find it.

To make sure that it works, you have to move this .so to bin/Debug/net5.0/ (basically a couple directories back). if the same error shows up after you've done that, then it's likely a dependency that libcvextern.so needs. You can check for its dependencies by doing ldd bin/Debug/net5.0/libcvextern.so. Something we've had at least twice is someone missing libgeotiff (which can be downloaded from the Arch community repositories if you're on an Arch-based distro).

karmek-k commented 3 years ago

Sorry to not have mentioned that in a previous issue. This is a known bug: on Linux, EmguCV places its libcvextern.so runtime under bin/Debug/net5.0/runtimes/ubuntu.20.04-x64/native/ after a dotnet build, and then claims that it cannot find it.

To make sure that it works, you have to move this .so to bin/Debug/net5.0/ (basically a couple directories back). if the same error shows up after you've done that, then it's likely a dependency that libcvextern.so needs. You can check for its dependencies by doing ldd bin/Debug/net5.0/libcvextern.so. Something we've had at least twice is someone missing libgeotiff (which can be downloaded from the Arch community repositories if you're on an Arch-based distro).

After moving libcvextern.so and installing libgeotiff, the application is working. Thank you!

sr229 commented 3 years ago

I assume this was fixed already or does @adryzz need to do something more about this?

sr229 commented 3 years ago

whoops, clicked close issue on accident.

adryzz commented 3 years ago

Didn't test this branch yet so I'll be doing it today.

Speykious commented 3 years ago

I assume this was fixed already or does @adryzz need to do something more about this?

The specific bug is fixed on PR #242, which hasn't been merged yet. Though I still can't figure out anything for the "can't open camera by index" issue.

LeNitrous commented 3 years ago

Closing as debut is now released.