allo- / virtual_webcam_background

Use a virtual webcam background and overlays with body-pix and v4l2loopback
GNU General Public License v3.0
306 stars 48 forks source link

Help: FakeWebCam invalid syntax #42

Closed ghost closed 3 years ago

ghost commented 4 years ago
❯ virtualcam                                                                  ─╯
  File "/home/adminodchryz/virtual_webcam_background/virtual_webcam.py", line 101
    fakewebcam =droid FakeWebcam(config.get("virtual_video_device"), width, height)
                      ^
SyntaxError: invalid syntax

Hi!, just want to ask how to fix this, whenever i try to run virtualcam im getting this error, i open the directory on code to inspect and there is a class pointing to FakeWebcam from pyfakewebcam.py, but code also says that it is an invalid syntax

edit: I've set an alias virtualcam for the script so that i can call it without going to the directory

ghost commented 4 years ago

image

allo- commented 4 years ago

Your source file is not the same as in the git repo (the "droid" should not be there). Please run git checkout virtual_webcam.py to restore the original file.

ghost commented 4 years ago

git checkout virtual_webcam.py

after running git checkout virtual_webcam.py and runnning the virtual_webcam.py

❯ /usr/bin/python /home/adminodchryz/virtual_webcam_background/virtual_webcam.py ─╯ Reloading config. Traceback (most recent call last): File "/home/adminodchryz/virtual_webcam_background/virtual_webcam.py", line 101, in fakewebcam = FakeWebcam(config.get("virtual_video_device"), width, height) File "/home/adminodchryz/.local/lib/python3.8/site-packages/pyfakewebcam/pyfakewebcam.py", line 54, in init fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings) OSError: [Errno 22] Invalid argument

ghost commented 4 years ago

image image ❯ virtualcam ─╯ [ERROR:0] global /tmp/pip-req-build-6179nsls/opencv/modules/videoio/src/cap.cpp (140) open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.4.0) /tmp/pip-req-build-6179nsls/opencv/modules/videoio/src/cap_images.cpp:293: error: (-215:Assertion failed) !_filename.empty() in function 'open'

Failed to reduce capture buffer size. Latency will be higher! Traceback (most recent call last): File "/home/adminodchryz/virtual_webcam_background/virtual_webcam.py", line 101, in fakewebcam = FakeWebcam(config.get("virtual_video_device"), width, height) File "/home/adminodchryz/.local/lib/python3.8/site-packages/pyfakewebcam/pyfakewebcam.py", line 27, in init if not os.path.exists(video_device): File "/usr/lib/python3.8/genericpath.py", line 19, in exists os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

allo- commented 4 years ago

Copy config.yaml.example to config.yaml and set the parameters. See the readme and https://virtual-webcam.com/configuration.html

ghost commented 4 years ago

image i've already done that, still not working

allo- commented 4 years ago

Make sure you loaded the v4l2loopback Kernel Module and to get the real and fake webcam device ids right. Your useraccount also needs to be able to read from/write to the devices.

ghost commented 4 years ago

ive loaded the kernel module just like the instruction in the repo, then copied the created the config.yaml, and when its not working ive done a research and found out the website of yours, so I reloaded the kernel module using video_nr=0 instead of video_nr=2 but still not be able to work it out

allo- commented 4 years ago

You have two devices, which you can find with ls -l /dev/video*. One is the fake cam, the other one the real one. they are probably owned by the group "video" and your user must be in this group (log out and in again after changing the groups of your user) to use the devices.

Dazlarus commented 3 years ago

I am getting the same errors, but it is intermittent. I thought it might be related to not having all the dependencies or something like that. To rule out inconsistencies, each time I try to get this program to work after a reboot I rerun all the setup steps. I have included my config.yaml below in case that is somehow causing the issues since I do have to change the real_video_device parameter and I do make it passed this error message.

The fake cam is listed as a video device as shown in the screenshot below. This was an attempt with my C920 but I have also tried a Brio webcam as well.

width: 1280
height: 720
fps: 30
internal_resolution: 0.5
multiplier: 0.5
segmentation_threshold: 0.75
blur: 3
erode: 10
dilate: 10
virtual_video_device: "/dev/video10"
real_video_device: "/dev/video0"
average_masks: 3
mjpeg: False
layers:
  - "empty": [["image", "background.jpg"]]
  - "foreground": []

Screenshot from 2021-05-11 06-37-22

For full transparency I have yet to get this program to actually work but I frequently get to a stage where there are no more error messages before I have to give up. Been trying for the past 3 days.

allo- commented 3 years ago

Are you sure that's the config you used?

The error message looks like virtual_video_device is unset. you can try to add before like 101 (the line in the error message)

print(config['virtual_video_device'])

This should print the device from your config, but the error message looks like it will output a KeyError (.get replaces non-existent entries with None)

allo- commented 3 years ago

closed due to inactivity