A program to replace the background in your webcam image
ConfigurationThe settings are configured in config.yaml and an example file is provided in the git repository. The most important settings are:
- virtual_video_device: "/dev/video0" (when you used video_nr=0 when loading the kernel module).
- real_video_device: "/dev/video1"
- width: 1280
- height: 720
- segmentation_threshold: 0.75 (Threshold for separating foreground and background)
- layers (see the example config and README for how to configure the layers)
To optimize the boundary, you can use dilate and erode. Dilate will grow the foreground mask by a number of pixels and erode will shrink it again. This helps to remove small spots of background that are recognized wrong. You will often get a slightly too large foreground, so you may want to set erode to a bit larger value than dilate.
To remove the artifacts around your body, you may blur the boundary a bit using the blur setting. Finally you can optimize the mask update using the average_masks setting. A value of 1 means that only the current mask is used. This often leads to flickering in areas where the detection does not work good enough. By using a larger value you can reduce the flickering by averaging over the last few masks at the cost of getting afterimages when you move too fast. Usually 2 or 3 is a good value. Settings that usually work fine:
- segmentation_threshold: 0.75 (depending on the lighting and your (real) background)
- dilate: 10
- erode: 15
- blur: 5
- average_masks: 2
Back to the homepage