Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bendavis78 opened this issue Feb 24, 2021 · 3 comments

Comments

@bendavis78
Copy link

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-
Copy link
Owner

allo- commented Feb 24, 2021

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

@allo-
Copy link
Owner

allo- commented Feb 24, 2021

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

@z80z80z80
Copy link

z80z80z80 commented Apr 20, 2021

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:

  • make change in config.yaml
  • close all applications that use the camera
  • sudo modprobe -r v4l2loopback
  • sudo modprobe v4l2loopback devices=1 max_buffers=2 exclusive_caps=1 card_label="VirtualCam"
  • python virtual_webcam.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants