Skip to content

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

Open

Description

@bendavis78

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

Activity

  1. allo- commented on Feb 24, 2021

    @allo-
    Owner

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

  2. allo- commented on Feb 24, 2021

    @allo-
    Owner

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

  3. z80z80z80 commented on Apr 20, 2021

    @z80z80z80

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions