summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO34
-rw-r--r--.gitignore2
-rw-r--r--PKGBUILD77
-rwxr-xr-xautobuild.sh17
-rw-r--r--fake-background-bodypix.service14
-rw-r--r--fake-background-webcam.install13
-rw-r--r--fake-background-webcam@.service26
-rw-r--r--npmCache.md12
-rw-r--r--readme.md40
9 files changed, 235 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..e62ddbede75c
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,34 @@
+pkgbase = fake-background-webcam-git
+ pkgdesc = Virtual background-replacing camera
+ pkgver = r131.4fbb74b
+ pkgrel = 1
+ url = https://github.com/fangfufu/Linux-Fake-Background-Webcam
+ install = fake-background-webcam.install
+ arch = x86_64
+ license = GPL
+ makedepends = git
+ makedepends = npm
+ source = fake-background-webcam-git::git+https://github.com/fangfufu/Linux-Fake-Background-Webcam.git
+ source = fake-background-bodypix.service
+ source = fake-background-webcam@.service
+ source = readme.md
+ source = fake-background-webcam.install
+ sha256sums = SKIP
+ sha256sums = 24827ce9ae57cc11472c26ef4dc8edfa3218250a4ff6bba424f24bfe0eed3cb2
+ sha256sums = 9e8b5fb7fece0b1d2809b5dcb880419e85035f80f8fcaefc9cf9fe56017bf4d9
+ sha256sums = f6b37aff68926eb16c510db56df665ec2a3f8aa7348c0e8ddf247bcaa770a955
+ sha256sums = b57c70f3b498d646d8834d770d806219b306251c908cc8591b0d711e3638916f
+
+pkgname = fake-background-webcam-git
+
+pkgname = fake-background-bodypix-git
+ depends = v4l2loopback-dkms
+ depends = python
+ depends = akvcam-dkms
+ depends = opencv
+ depends = python-numpy>=1.18.2
+ depends = python-requests>=2.23.0
+ depends = python-requests-unixsocket
+ depends = python-aiohttp>=3.6.2
+ depends = python-pyfakewebcam
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..7bb8b0ae1f12
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.pkg.tar.xz
+fake-background-webcam-git
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..4995109699af
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,77 @@
+# Maintainer: Premysl Srubar <premysl.srubar[äT]gmail(.)com>
+pkgbase=fake-background-webcam-git
+_pkgname="${pkgbase%-git}"
+
+pkgname=('fake-background-webcam-git' 'fake-background-bodypix-git')
+pkgver=r131.4fbb74b
+pkgrel=1
+pkgdesc="Virtual background-replacing camera"
+#optdepends=('cuda: for GPU acceleration of the TensorFlow on NVidia cards')
+arch=('x86_64')
+url="https://github.com/fangfufu/Linux-Fake-Background-Webcam"
+license=("GPL")
+makedepends=('git' 'npm')
+#provides=('fake-background-webcam' 'fake-background-bodypix')
+#conflicts=('fake-background-webcam' 'fake-background-bodypix')
+
+source=("${pkgname}::git+${url}.git"
+ 'fake-background-bodypix.service'
+ 'fake-background-webcam@.service'
+ 'readme.md'
+ "$_pkgname.install")
+
+sha256sums=('SKIP'
+ '24827ce9ae57cc11472c26ef4dc8edfa3218250a4ff6bba424f24bfe0eed3cb2'
+ '9e8b5fb7fece0b1d2809b5dcb880419e85035f80f8fcaefc9cf9fe56017bf4d9'
+ 'f6b37aff68926eb16c510db56df665ec2a3f8aa7348c0e8ddf247bcaa770a955'
+ 'b57c70f3b498d646d8834d770d806219b306251c908cc8591b0d711e3638916f')
+
+install=$_pkgname.install
+
+pkgver() {
+ cd "$srcdir/${pkgname}"
+ printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
+ #git show -s --format="%ci" HEAD | sed -e 's/-//g' -e 's/ .*//'
+}
+
+package_fake-background-webcam-git() {
+ cd "$srcdir/${pkgbase}/fakecam"
+ install -d "$pkgdir/usr/lib/$_pkgname"
+ install -Dm644 *.py "$pkgdir/usr/lib/$_pkgname"
+
+ install -d "$pkgdir/var/lib/$_pkgname/default"
+ install -Dm644 *.jpg *.png "$pkgdir/var/lib/$_pkgname/default"
+ install -Dm644 "${srcdir}/fake-background-webcam@.service" "$pkgdir/usr/lib/systemd/system/$_pkgname@.service"
+
+ install -v -m 644 -D "${srcdir}/readme.md" "${pkgdir}/usr/share/doc/${_pkgname}/readme.md"
+}
+
+
+package_fake-background-bodypix-git() {
+ depends=('v4l2loopback-dkms' 'python' 'akvcam-dkms' 'opencv' 'python-numpy>=1.18.2' 'python-requests>=2.23.0' 'python-requests-unixsocket' 'python-aiohttp>=3.6.2' 'python-pyfakewebcam')
+
+
+ install -Dm644 "${srcdir}/fake-background-bodypix.service" "$pkgdir/usr/lib/systemd/system/fake-background-bodypix.service"
+
+ #./install.sh
+ mkdir -p "${pkgdir}/usr/lib/node_modules"
+
+ cd "$srcdir/${pkgbase}/bodypix"
+ rm Dockerfile*
+ npm pack .
+ npm install --user root -g --cache "${srcdir}/npm-cache" --prefix "$pkgdir/usr" *.tgz
+ rm bodypix-*.tgz
+
+ # Non-deterministic race in npm gives 777 permissions to random directories.
+ # See https://github.com/npm/npm/issues/9359 for details.
+ find "${pkgdir}"/usr -type d -exec chmod 755 {} +
+
+ # npm gives ownership of ALL FILES to build user
+ # https://bugs.archlinux.org/task/63396
+ chown -R root:root "$pkgdir"
+
+ find "${pkgdir}" -name "package.json" -exec sed -e "s|${pkgdir}||" -i {} \;
+ find "${pkgdir}" -name "package.json" -exec sed -e "s|${srcdir}||" -i {} \;
+
+
+}
diff --git a/autobuild.sh b/autobuild.sh
new file mode 100755
index 000000000000..7f856725fd54
--- /dev/null
+++ b/autobuild.sh
@@ -0,0 +1,17 @@
+#! /bin/bash
+function block_for_change
+{
+ inotifywait -r -e modify,move,create,delete .
+}
+
+
+while block_for_change; do
+ echo CHANGE
+ sudo systemctl daemon-reload
+ sudo systemctl stop fake-background-webcam@1.service
+ sudo systemctl start fake-background-webcam@1.service
+ sleep 1
+ clear
+ sudo systemctl status -n40 --no-pager fake-background-webcam@1.service
+
+done
diff --git a/fake-background-bodypix.service b/fake-background-bodypix.service
new file mode 100644
index 000000000000..39ab3d449d6b
--- /dev/null
+++ b/fake-background-bodypix.service
@@ -0,0 +1,14 @@
+[Unit]
+Description =Fake Background Webcam - bodypix mask detector
+Requires=dbus.socket
+#After=dbus.socket
+
+[Service]
+Type = simple
+WorkingDirectory=/usr/lib/node_modules/bodypix
+Environment=NODE_ENV=production
+ExecStart=/usr/bin/node app.js $FAKE_BACKGROUND_BODYPIX_ARGS
+
+[Install]
+#WantedBy=sockets.target
+WantedBy=default.target
diff --git a/fake-background-webcam.install b/fake-background-webcam.install
new file mode 100644
index 000000000000..f5d2717042ff
--- /dev/null
+++ b/fake-background-webcam.install
@@ -0,0 +1,13 @@
+post_install() {
+ systemctl daemon-reload
+ cat<<'EOL'
+run:
+ systemctl start fake-background-webcam@0.service
+
+see: "/usr/share/doc/fake-background-webcam/readme.md" for more details
+EOL
+
+}
+post_upgrade() {
+ post_install
+}
diff --git a/fake-background-webcam@.service b/fake-background-webcam@.service
new file mode 100644
index 000000000000..588c1cccc361
--- /dev/null
+++ b/fake-background-webcam@.service
@@ -0,0 +1,26 @@
+[Unit]
+Description =Fake Background Webcam - frame-source /dev/video%i -> /dev/video2%i
+BindsTo=fake-background-bodypix.service
+After=fake-background-bodypix.service
+
+
+[Service]
+Type = simple
+WorkingDirectory=/usr/lib/fake-background-webcam
+Environment="IMAGE_FOLDER=/var/lib/fake-background-webcam/default"
+ExecStartPre=modprobe v4l2loopback video_nr=2%i card_label="Fake background %i" exclusive_caps=1
+
+
+ExecStart=/usr/bin/python fake.py \
+ --webcam-path /dev/video%i \
+ --v4l2loopback-path /dev/video2%i \
+ --image-folder $IMAGE_FOLDER \
+ $FAKE_BACKGROUND_WEBCAM_ARGS
+
+ExecReload=/bin/kill -s INT $MAINPID
+ExecStopPost=-modprobe -r v4l2loopback
+
+
+[Install]
+#WantedBy=sockets.target
+WantedBy=default.target
diff --git a/npmCache.md b/npmCache.md
new file mode 100644
index 000000000000..3eb4a740e1b0
--- /dev/null
+++ b/npmCache.md
@@ -0,0 +1,12 @@
+
+https://github.com/runk/npm-proxy-cache
+
+ ```
+ docker run -it -p 8880:8080 npm-proxy-cache --ttl $[24*60*60] --host 0.0.0.0 --expired
+```
+
+```
+ npm config set proxy http://localhost:8880/
+ npm config set https-proxy http://localhost:8880/
+ npm config set strict-ssl false
+```
diff --git a/readme.md b/readme.md
new file mode 100644
index 000000000000..3d3624e53d83
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,40 @@
+
+## Basic usage
+The systemd service instance name is mapped to the video device number. So for example:
+
+```sh
+systemctl start fake-background-webcam@0.service
+```
+
+would use `/dev/video0` as the source and create `/dev/video20` as the virutal camera with fake background.
+
+## Customization
+Override the systemd unit file:
+
+```sh
+systemctl edit fake-background-webcam@0.service
+#edit
+systemctl daemon-reload
+systemctl restart fake-background-webcam@0.service
+```
+
+
+```sh
+[Service]
+# Change folder with background/mask images and add additional arguments
+# See https://github.com/fangfufu/Linux-Fake-Background-Webcam#fakecamfakepy
+Environment=IMAGE_FOLDER=/home/myBackground FAKE_BACKGROUND_WEBCAM_ARGS="--hologram --scale-factor 1"
+
+# To avoid automatic loading/removing of the v4l2loopback kernel module
+ExecStartPre=
+ExecStartPost=
+
+
+```
+
+It is possible to have multiple cameras sharing the same bodypix detector. Only disable the `Pre/Post` commands (for all `@` instances) as shown above and load the modules manually. For example:
+
+```sh
+modprobe v4l2loopback video_nr=20,21 card_label="Fake Background cam1","Fake Background cam2" exclusive_caps=1
+
+```