# WebCam Remove Background
A Python script to remove background of a webcam image and stream the result into a virtual video device. The background removal is based on face detection with OpenCV within each image.
## Requirements
- Tested with Python 3.7
- Requires [V4L2-Loopback](https://github.com/umlaeute/v4l2loopback).
In Ubuntu this is available as the package `v4l2loopback-utils` and its dependencies. **HOWEVER** under Ubuntu 18.04 with recent Kernel, the module has a [bug](https://github.com/umlaeute/v4l2loopback/issues/172) (see [here](https://github.com/jremmons/pyfakewebcam/issues/5#issuecomment-612167782) also). Hence, it is advised to install `v4l2loopback` from github source.
## Usage
1. create a virtual video device
```bash
$ sudo modprobe v4l2loopback devices=1 video_nr=20 card_label='v4l2loopback' exclusive_caps=1
```
2. Make sure you the video device `/dev/video20` has been created.
3. Run `python removeCamBg.py`
## Command line arguments
See `python removeCamBg.py --help`.
```
usage: removeCamBg.py [-h] [-b BACKGROUND] [-u MASK_UPDATE] [-d MASK_DECAY]
[-m MASK_MAX] [-c CAMERA_ID] [--debug]
Read a webcam image and replace all background with pixels from a custom
image.
optional arguments:
-h, --help show this help message and exit
-b BACKGROUND, --background BACKGROUND
Filename of the background image. By default, it's a
noisy image
-u MASK_UPDATE, --mask-update MASK_UPDATE
Update the face mask every u frames
-d MASK_DECAY, --mask-decay MASK_DECAY
Upon losing the face, how fast shall the face fade
away. Between 0 and 1. 0 Means to delete mask
immediately, 1 means keep mask forever.
-m MASK_MAX, --mask-max MASK_MAX
Maximum blending factor of the detected face, between
0 and 1. 1 means the face is not transparent at all. 0
means face it not visible at all
-c CAMERA_ID, --camera-id CAMERA_ID
Id of the video capturing device to open. Will use 0
by default, that will open the default backend camera.
--debug If set, show the resulting image in a debug window
```
## Example Result
Holding a newspaper in front of the camera yields these results.
Input image:
![](doc/before.png)
Output image with some blending.
![](doc/after.png)
没有合适的资源?快使用搜索试试~ 我知道了~
webcamremovebg:删除网络摄像头图像的背景并将结果流式传输到虚拟视频设备中
共8个文件
png:2个
py:1个
gitignore:1个
需积分: 24 4 下载量 160 浏览量
2021-05-09
21:24:04
上传
评论
收藏 1.38MB ZIP 举报
温馨提示
WebCam删除背景 一个Python脚本,用于删除网络摄像头图像的背景并将结果流式传输到虚拟视频设备中。 背景去除基于每个图像内使用OpenCV进行的人脸检测。 要求 经过Python 3.7测试 需要 。 在Ubuntu中,它可以作为软件包v4l2loopback-utils及其依赖项使用。 但是,在具有最新内核的Ubuntu 18.04下,该模块存在(另请参见)。 因此,建议从github源安装v4l2loopback 。 用法 创建一个虚拟视频设备$ sudo modprobe v4l2loopback devices=1 video_nr=20 card_label= ' v4l2loopback ' exclusive_caps=1 确保已创建视频设备/dev/video20 。 运行python removeCamBg.py 命令行参数 参见python removeCa
资源详情
资源评论
资源推荐
收起资源包目录
webcamremovebg-master.zip (8个子文件)
webcamremovebg-master
.gitignore 2KB
requirements.txt 44B
LICENSE 1KB
doc
before.png 451KB
after.png 951KB
haarcascade_frontalface_default.xml 908KB
README.md 2KB
removeCamBg.py 4KB
共 8 条
- 1
龙窑溪
- 粉丝: 31
- 资源: 4520
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 单家独院式农房户型设计110平-t3.dwg
- 有了DevExpress VCL 23.2.6 Full Source 这个版本源码,怎么能没有相应的Demo呢
- GIN+SCUI企业级后台管理系统;后端基于go语言开发,前端基于vue3开发的scui框架
- 单家独院式图纸110平方米户型水电图.dwg
- aardio - 阿里云mqtt实例
- 基于python后端开发框架
- seata-server 1.4.0和2.0.0
- signal-and-system信号与系统
- career.it.signals-systems信号与系统
- 基于TCP-IP实现的斗地主游戏(ARM-LINUX)C源码-95分以上课程设计
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0