allo- / virtual_webcam_background

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

Getting error: frame height does not match the height of webcam device: 540!=480 #63

Open bendavis78 opened 3 years ago

bendavis78 commented 3 years ago

Here's my config.yml:

segmentation_threshold: 0.7
blur: 5
erode: 10
dilate: 10
virtual_video_device: "/dev/video2"
real_video_device: "/dev/video0"
average_masks: 2
mjpeg: False
layers:
  - "empty": [["image", "background.jpg"]]
  - "foreground": []

When i run ./virtual_webcam.py, I get the following error:

$ ./virtual_webcam.py
Reloading config.
Model: mobilenet (multiplier=0.5, stride=16)
Loading model...
done.
Traceback (most recent call last):
  File "/home/ben/.local/src/virtual_webcam_background/./virtual_webcam.py", line 315, in <module>
    mainloop()
  File "/home/ben/.local/src/virtual_webcam_background/./virtual_webcam.py", line 309, in mainloop
    fakewebcam.schedule_frame(frame)
  File "/home/ben/.local/lib/python3.9/site-packages/pyfakewebcam/pyfakewebcam.py", line 68, in schedule_frame
    raise Exception('frame height does not match the height of webcam device: {}!={}\n'.format(self._settings.fmt.pix.height, frame.shape[0]))
Exception: frame height does not match the height of webcam device: 540!=480
allo- commented 3 years ago

What is the size of background.jpg? Try to scale/crop it to the resolution of your webcam.

allo- commented 3 years ago

See also #62. Maybe you have the same issue?

z80z80z80 commented 3 years ago

I've experienced a similar issue and was able to fix it for myself. It turns out after creating the v4l2loopback device and using it once, you can't change the resolution without hitting this error.

My process for resolution changes is: