fangfufu / Linux-Fake-Background-Webcam

Faking your webcam background under GNU/Linux, now supports background blurring, animated background, colour map effect, hologram effect and on-demand processing.
GNU General Public License v3.0
1.61k stars 161 forks source link

fake.py freaks out when trying to access with chrome #25

Closed mtedaldi closed 4 years ago

mtedaldi commented 4 years ago

Hi. Since I have no Webcam on my system I had to do a few more tricks. I'm using my DSLR as webcam via gphoto2 and v4l2loopback. So my modprobe looks like this

sudo modprobe v4l2loopback video_nr=0,2 exclusive_caps=1,1 card_label="EOS 7D mkII","Fake Webcam" (Creating 2 devices, video0 and video2, each with exclusive_caps=1).

This way I can run the software without any changes. I can access both streams with VLC and everything runs fine.

BUT when I want to access the Webcams from google chrome (using jitsi for video chat), fake.py "freaks out". Seems, it can't get the mask anymore.

marco@schwipschwap:~/build/Linux-Fake-Background-Webcam/fakecam$ python3 fake.py -f 12
Running...
Please CTRL-C to reload the background / foreground images
Please CTRL-\ to exit
Mask request failed, retrying: OpenCV(4.2.0) /io/opencv/modules/imgproc/src/resize.cpp:4045: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

Traceback (most recent call last):
  File "fake.py", line 106, in get_frame
    mask = await self._get_mask(frame, session)
  File "fake.py", line 56, in _get_mask
    frame = cv2.resize(frame, (0, 0), fx=self.scale_factor, fy=self.scale_factor)
cv2.error: OpenCV(4.2.0) /io/opencv/modules/imgproc/src/resize.cpp:4045: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

It's the same behaviour with or without the option "- f 12". That's just that my camera doesn't deliver more FPS over USB, so why should I waste a lot of processing power.

Tested jitsi with Firefox and there is no issue (but Jitsi is unbearably sluggish in firefox).

There are quite some people having issues accessing v4l2loopback "cameras" with chrome. But they normally just get "no picture" or "device not detected". But that chrome seems to be able to crash the video source seems really strange!

fangfufu commented 4 years ago

This is the limitation of v4l2loopback, please refer to https://github.com/umlaeute/v4l2loopback/issues/78.

mtedaldi commented 4 years ago

Sadly, this does not really help. In my case, the "cam" IS detected but fake.js stops working as soon as I connect with chrome. I'm guess, it's really a problem with chrome but the behaviour is different (or I missed the relevant information there). (No, I did not read the whole thing in 6 minutes, I've read this stuff before opening the issue here)

fangfufu commented 4 years ago

Well, my point is that this problem has got nothing to do with these scripts. It has got to do with Chrome or v4l2loopback.

fangfufu commented 4 years ago

@mtedaldi, you could potentially output stream of this webcam to webcamoid + akvcam, if you are desperate for chrome.

fangfufu commented 4 years ago

@mtedaldi , I added support for akvcam, it should work with Chrome.

mtedaldi commented 4 years ago

Thank you very much! I'll try as soon as possible!