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

How can I make this into a service? #154

Open
RemyFV opened this issue Sep 3, 2021 · 10 comments
Open

How can I make this into a service? #154

RemyFV opened this issue Sep 3, 2021 · 10 comments
Labels
enhancement New feature or request resolved_but_not_merged The problem is resolved, but the changes have not been committed yet.

Comments

@RemyFV
Copy link

RemyFV commented Sep 3, 2021

thanks for your tool, Fangfufu! it works great and it's literally the only one that does so without much hassle :)

I have been looking for a way to make it into a background service that would start when I log in, so that it's always available (since it's paused when unused).

do you have any recommendation for this? my venture into systemd was unsuccessful.

@fangfufu
Copy link
Owner

fangfufu commented Sep 3, 2021

Nope, I don't have any suggestions on how to do this, and I don't recommend you do this either. To be honest, I am really surprised to hear you want to do this, considering how unstable it can be - sometimes the instability is not even my problem (#127).

@fangfufu fangfufu added the help wanted Extra attention is needed label Sep 3, 2021
@ruifm
Copy link

ruifm commented Sep 3, 2021

Add this to /etc/udev/rules.d/webcam.rules to create systemd bind devices for /dev/videoX system devices.

KERNEL=="video0", SYMLINK="video0", TAG+="systemd"
KERNEL=="video1", SYMLINK="video1", TAG+="systemd"

do it for as much devices as needed.

Then, for instance ~/.config/sytemd/user/fakecam.service:

[Unit]
Description=Linux Fake Background Webcam
BindsTo=dev-video0.device
After=dev-video0.device
BindsTo=dev-video1.device
After=dev-video1.device

[Service]
Type=simple
ExecStart=/full/path/to/fake.py

[Install]
WantedBy=default.target

Again add BindsTo= and After= to as many video devices as you need.

The ExecStart depends on how you have the project installed, you can use %h to indicate the user's home directory if you need.

Personally, I have it setup using a python virtualenv so I actually call a wrapper script I called fakecam:

#!/usr/bin/env sh

cwd=$PWD
cd /full/path/to/Linux-Fake-Background-Webcam || exit
. ./env/bin/activate
./fake.py
deactivate
cd "$cwd" || exit

And I use that in ExecStart instead.

@RemyFV
Copy link
Author

RemyFV commented Sep 3, 2021

that is cool, thank you very much.

I'll see if it breaks my laptop over time :)

@fangfufu
Copy link
Owner

fangfufu commented Sep 3, 2021

@ruifm , thanks a lot! If you have any scripts / tips on setting up venv, please submit a pull request, or opening up an issue. I plan to work on it later, I just haven't got around to do it yet.

@fangfufu
Copy link
Owner

fangfufu commented Sep 3, 2021

@RemyFV , it is not going to break your laptop over time. Personally I find it easier to run it in a terminal. So I know when things break down.

@ruifm , @RemyFV , please share your OS version, v4l2loopback version, Python version, Mediapipe version, Numpy version, if you don't mind. There are other users who experience stability issues. I think they would appreciate these info.

@RemyFV
Copy link
Author

RemyFV commented Sep 3, 2021

I'm on debian 12, v4l2loopback from repo so 0.12.5 I guess. I'll check the rest out tomorrow and come back to you.

it's very stable for me - went on 30m 1h calls without any issues. the only little problem I have is that I need to set the threshold to something like 5 to get a usable picture even with my actual green screen background, but I'm more than understanding here.

the hologram filter makes it look cool, even :)

@ruifm
Copy link

ruifm commented Sep 3, 2021

@ruifm If you have any scripts / tips on setting up venv, please submit a pull request, or opening up an issue. I plan to work on it later, I just haven't got around to do it yet.

Imo setting up a python venv is such a simple thing it does not warrant special docs, but maybe I do not represent the majority. A simple comprise would be suggesting setting up a venv and linking to the arch wiki on how to do it but that decision is up to you, I'm not good on writing user docs 😉

@ruifm , @RemyFV , please share your OS version, v4l2loopback version, Python version, Mediapipe version, Numpy version, if you don't mind. There are other users who experience stability issues. I think they would appreciate these info.

Well, I'm not experiencing any stability issues but ok:

  • os: archlinux (kernel 5.12.13)
  • v4l2loopback: 0.12.5-1 v4l2loopback-dmks from archlinux repos
  • python: 3.9.6 (system python)
  • mediapipe: 0.8.7.1 (from just using a python venv and running pip -r requirements.txt)
  • numpy: 1.21.2 (same origin as mediapipe)

@fangfufu
Copy link
Owner

fangfufu commented Sep 3, 2021

@RemyFV , I am very surprised that you need to change threshold and you have an actual green screen. It works reasonably well in my cluttered background, until I hang up my washings. It thinks my clothes is an actual person.

@RemyFV
Copy link
Author

RemyFV commented Sep 3, 2021

the camera on my Thinkpad T480s is bad and my lighting isn't that good either. I'll send you some before / after pictures in a PM, you'll tell me if it looks normal to you !

@fangfufu fangfufu added enhancement New feature or request and removed help wanted Extra attention is needed labels Sep 4, 2021
@RemyFV
Copy link
Author

RemyFV commented Sep 7, 2021

Debian 12 Bookworm, kernel 5.10.0-8-amd64
v4l2loopback 0.12.5 (from the official github repository)
Python 3.9.7 (from debian 12 repository, not 100% sure)
mediapipe 0.8.7.1
numpy 1.19.5 (both from pip -r requirements.txt)

I sent you a mail with screenshots for the threshold thing!

@fangfufu fangfufu added resolved_but_not_merged The problem is resolved, but the changes have not been committed yet. resolved and removed resolved labels Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request resolved_but_not_merged The problem is resolved, but the changes have not been committed yet.
Projects
None yet
Development

No branches or pull requests

3 participants