Coder Social home page Coder Social logo

Comments (25)

blueOkiris avatar blueOkiris commented on September 28, 2024 1

Or you can just delete the .venv, git stash, git pull, and try again

from bgrm.

athyla avatar athyla commented on September 28, 2024 1

Yes, I have ffmpeg 4 installed.
I have also tried out installing 2 python packages relating to ffmpeg, but it did not help: python39-ffmpeg-python and python39-imageio-ffmpeg.

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024 1

That's a cool idea for a feature. It would definitely be possible. I'll look into adding it when I get a chance

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024 1

Also, I don't know if you're using it or not, but there's a great little tool for managing multiple python versions called pyenv

I typically have whatever the most recent version of python is installed via my system, and then I'll have pyenv have python 3.8 and maybe 3.7. I use it a lot more for my job than than personal stuff tho

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

Thanks for the kernel info. That's a good idea to add kernel headers as a dependency.

As for the other issue, I think it may be that Python 3.9 is not your default Python version, so in scripts/setup-env.sh I need to change so that it forces that version which was an oversight on my part.

I would suggest deleting .venv, stashing your changes, editing scripts/setup-venv.sh so that instead of the first pip3 it says python3.9 -m pip and instead of virtualenv it says python3.9 -m virtualenv, and running sudo ./bgrm.sh again.

from bgrm.

athyla avatar athyla commented on September 28, 2024

Thanks, I removed .venv, I pulled the latest changes and now it uses python3.9, so the last problem is solved.
However now I have a problem with xcb:

...
Matplotlib is building the font cache; this may take a moment.
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/user/Applications/bgrm/.venv/lib64/python3.9/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

./bgrm.sh: line 32:  4184 Aborted                 (core dumped) python3.9 bgrm $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22} ${23}

I've checked and I have this:
/home/user/Applications/bgrm/.venv/lib64/python3.9/site-packages/cv2/qt/plugins/platforms/libqxcb.so

Any ideas?

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

Can you delete .venv, run export QT_DEBUG_PLUGIN=1, and run bgrm.sh again and tell me the extra info it gives?

According to what I've found online for similar issues, this is most likely another dependency issue. Something to do with X.

from bgrm.

athyla avatar athyla commented on September 28, 2024

It's mostly the same output, here is everything:


sudo ./bgrm.sh -b ~/Pictures/Teams/ISS-cupola.webp -H 720
Initializing virtual environment!
Requirement already satisfied: virtualenv in /usr/local/lib/python3.9/site-packages (20.8.1)
Requirement already satisfied: backports.entry-points-selectable>=1.0.4 in /usr/local/lib/python3.9/site-packages (from virtualenv) (1.1.0)
Requirement already satisfied: distlib<1,>=0.3.1 in /usr/local/lib/python3.9/site-packages (from virtualenv) (0.3.3)
Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3.9/site-packages (from virtualenv) (1.16.0)
Requirement already satisfied: platformdirs<3,>=2 in /usr/local/lib/python3.9/site-packages (from virtualenv) (2.4.0)
Requirement already satisfied: filelock<4,>=3.0.0 in /usr/local/lib/python3.9/site-packages (from virtualenv) (3.3.1)
created virtual environment CPython3.9.7.final.0-64 in 187ms
  creator CPython3Posix(dest=/home/user/Applications/bgrm/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
    added seed packages: pip==21.2.4, setuptools==58.1.0, wheel==0.37.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Collecting opencv-python<=4.4.0.46
  Downloading opencv_python-4.4.0.46-cp39-cp39-manylinux2014_x86_64.whl (49.5 MB)
     |████████████████████████████████| 49.5 MB 6.7 MB/s 
Collecting opencv-contrib-python<=4.4.0.46
  Downloading opencv_contrib_python-4.4.0.46-cp39-cp39-manylinux2014_x86_64.whl (55.7 MB)
     |████████████████████████████████| 55.7 MB 509 kB/s 
Collecting mediapipe
  Downloading mediapipe-0.8.8.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.0 MB)
     |████████████████████████████████| 34.0 MB 16.3 MB/s 
Collecting cvzone
  Downloading cvzone-1.5.2.tar.gz (12 kB)
Collecting v4l2
  Downloading v4l2-0.2.tar.gz (23 kB)
Collecting numpy>=1.19.3
  Downloading numpy-1.21.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
     |████████████████████████████████| 15.7 MB 4.2 MB/s 
Collecting protobuf>=3.11.4
  Downloading protobuf-3.19.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
     |████████████████████████████████| 1.1 MB 9.8 MB/s 
Collecting six
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting absl-py
  Downloading absl_py-0.15.0-py3-none-any.whl (132 kB)
     |████████████████████████████████| 132 kB 9.3 MB/s 
Collecting attrs>=19.1.0
  Downloading attrs-21.2.0-py2.py3-none-any.whl (53 kB)
     |████████████████████████████████| 53 kB 9.5 MB/s 
Collecting matplotlib
  Downloading matplotlib-3.4.3-cp39-cp39-manylinux1_x86_64.whl (10.3 MB)
     |████████████████████████████████| 10.3 MB 9.2 MB/s 
Requirement already satisfied: wheel in ./.venv/lib/python3.9/site-packages (from mediapipe->-r bgrm/requirements.txt (line 3)) (0.37.0)
Collecting pyparsing>=2.2.1
  Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
     |████████████████████████████████| 67 kB 9.1 MB/s 
Collecting pillow>=6.2.0
  Downloading Pillow-8.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
     |████████████████████████████████| 3.1 MB 6.4 MB/s 
Collecting cycler>=0.10
  Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Collecting python-dateutil>=2.7
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247 kB 10.1 MB/s 
Collecting kiwisolver>=1.0.1
  Downloading kiwisolver-1.3.2-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 7.4 MB/s 
Building wheels for collected packages: cvzone, v4l2
  Building wheel for cvzone (setup.py) ... done
  Created wheel for cvzone: filename=cvzone-1.5.2-py3-none-any.whl size=18356 sha256=f3157c80b41d46f49a0385d92fa3e55c91e0fd5a2599a3a10df7fdb896b06109
  Stored in directory: /tmp/pip-ephem-wheel-cache-d409enza/wheels/ff/ff/78/f15b81e678d85bfa09b5628c5345e3f04c4cef28e1effbd248
  Building wheel for v4l2 (setup.py) ... done
  Created wheel for v4l2: filename=v4l2-0.2-py3-none-any.whl size=19436 sha256=b4765d47f155be990a754d3fab3ec64b8caa66464122e0ce8b957bfa4c1af71a
  Stored in directory: /tmp/pip-ephem-wheel-cache-d409enza/wheels/43/9b/03/b4299b27c192c5b8025553da7d8d231a97244cfcd1d4914bca
Successfully built cvzone v4l2
Installing collected packages: six, python-dateutil, pyparsing, pillow, numpy, kiwisolver, cycler, protobuf, opencv-python, opencv-contrib-python, matplotlib, attrs, absl-py, v4l2, mediapipe, cvzone
Successfully installed absl-py-0.15.0 attrs-21.2.0 cvzone-1.5.2 cycler-0.10.0 kiwisolver-1.3.2 matplotlib-3.4.3 mediapipe-0.8.8.1 numpy-1.21.3 opencv-contrib-python-4.4.0.46 opencv-python-4.4.0.46 pillow-8.4.0 protobuf-3.19.0 pyparsing-2.4.7 python-dateutil-2.8.2 six-1.16.0 v4l2-0.2
WARNING: You are using pip version 21.2.4; however, version 21.3 is available.
You should consider upgrading via the '/home/user/Applications/bgrm/.venv/bin/python -m pip install --upgrade pip' command.
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/user/Applications/bgrm/.venv/lib64/python3.9/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

./bgrm.sh: line 32:  5969 Aborted                 (core dumped) python3.9 bgrm $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22} ${23}

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

Hmm. No extra info.

Well, one thing that might work is installing the qt5-base package and rerunning. That might be a dependency I already had installed that I didn't think I needed (makes sense bc I believe OpenCV uses Qt to draw its Windows)

I think that's an Arch package though, so I don't know what the equivalent openSUSE one would be. Looking into it

from bgrm.

athyla avatar athyla commented on September 28, 2024

I have also looked around for a solution.
For now I have tried:

  • using 4.3.0.36 in requirements.txt and export DISPLAY=:1.0
  • adding PyQt5 to requirements.txt

But none of the above helped, same output.

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

Just to be sure since it says "could not connect to display," you are running this in a graphical environment, right?

from bgrm.

athyla avatar athyla commented on September 28, 2024

Just to be sure since it says "could not connect to display," you are running this in a graphical environment, right?

Yes, I'm on Gnome 41.0 using xorg, but I have Qt apps installed, so I should have qt5 libs installed.

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

Okay that's good to know. That will eliminate some possibilities

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

According to the comments on a stack overflow question with similar output, it can be solved by installing libgqt5gui. One way to do it on suse is to install libQt5Gui5:

zypper addrepo https://ftp.lysator.liu.se/pub/opensuse/repositories/KDE:/Qt5/openSUSE_Factory/ kde-5-x86_64
zypper install libQt5Gui5

I would think that if you have Qt apps you should have the dependencies, but perhaps you don't have Qt_5_'s Gui lib

from bgrm.

athyla avatar athyla commented on September 28, 2024

Thanks for looking that up!
Yes, I checked and I have libQt5Gui5 installed from the default repos.

I also checked a few other recommendations from the web, but no luck until now, same results.

from bgrm.

athyla avatar athyla commented on September 28, 2024

Hello!

I've tried again the latest version, cloning it totally fresh.
I have the same xcb problem as before, for which unfortunately I could not find a solution.
To avoid xcb, I have tried out the --disable_window option and I got the following output:


user@machine:~/Applications/bgrm> sudo ./bgrm.sh --blur --disable_window
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/user/Applications/bgrm/bgrm/__main__.py", line 4, in <module>
    main()
  File "/home/user/Applications/bgrm/bgrm/bgrm.py", line 28, in main
    formatVirtualCamera(settings, virtCam, cam)
  File "/home/user/Applications/bgrm/bgrm/bgrm.py", line 66, in formatVirtualCamera
    ioctl(virtCam, VIDIOC_S_FMT, format)
OSError: [Errno 25] Inappropriate ioctl for device

Any ideas about this OSError: [Errno 25] Inappropriate ioctl for device?

Thanks!

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

That was smart to disable the window. I probably should have thought of and suggested that since the problem before was with the gui.

Anyway, the new issue sounds to me like you may be using the wrong input camera.
Default is 0 (/dev/video0), but you can set it with one of the tags (-c/--camera).
To check what video devices you have do ls /dev | grep video

from bgrm.

athyla avatar athyla commented on September 28, 2024

I have the following camera indexes: 0, 1, 10 and 2.
Every index except the default one gives the following output:


user@machine:~/Applications/bgrm> sudo ./bgrm.sh --blur --disable_window -c 2
[ WARN:0] global /tmp/pip-req-build-v1rk7obu/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video2): can't open camera by index
Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/user/Applications/bgrm/bgrm/__main__.py", line 4, in <module>
    main()
  File "/home/user/Applications/bgrm/bgrm/bgrm.py", line 27, in main
    with Cam(settings) as cam, open('/dev/video10', 'wb') as virtCam:
  File "/home/user/Applications/bgrm/bgrm/cam.py", line 22, in __init__
    _height, _width, self.channels = baseFrame.shape
AttributeError: 'NoneType' object has no attribute 'shape'
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

Yeah, that's not the issue then; 0 is the correct one if the others give that output.

I'm unsure then what the issue is, but one thing that can cause OpenCV ioctl errors according to duckduckgo is a missing dependency for ffmpeg. It is trying to format the video stream properly to create a virtual camera, so that could make sense

Do you have that installed? I don't have it as a dependency, so if that fixes it, I need to add it to the list.

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

I realize you probably have forgotten about this by now, but I recently ran into this issue myself after switching to GNOME and Fedora and fixed it for myself

I solved it by looking for the video device list: ls /sys/devices/virtual/video4linux

My actual device had become /dev/video1, and my virtual device was not 10 like it should be. It was /dev/video0

So whatever is in /sys/devices/virtual/video4linux, change the video_nr part of the modprobe line in bgrm.sh and the with Cam(settings) line in bgrm.py to match whatever is under there

bgrm.py:

with Cam(settings) as cam, open('<whatever is under /sys/devices/virtual/video4linux>', 'wb') as virtCam:

Example: with Cam(settings) as cam, open('/dev/video0', 'wb') as virtCam

bgrm.sh:

modprobe v4l2loopback \
    devices=1 exclusive_caps=1 video_nr=<just the number of whatever is under /sys/devices/virtual/video4linux> max_buffers=2 \
    card_label=v4l2lo

Example:

modprobe v4l2loopback \
    devices=1 exclusive_caps=1 video_nr=0 max_buffers=2 \
    card_label=v4l2lo

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

Closing bc old

from bgrm.

athyla avatar athyla commented on September 28, 2024

Hey blueOkiris!

Thanks for responding to this even after such a long time. You are right, I did not solve this problem and after trying a few other solution for Linux, I gave up.

After your message, I have retried bgrm following the updated readme, without building it, just installing it with pip. It installed fine, but when I try to execute it, it throws an error:

python3.8 -m bgrm -b ~/Pictures/bkg.png -w 320 -H 240 -s 2.0
Traceback (most recent call last):
  File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/attila/.local/lib/python3.8/site-packages/bgrm/__main__.py", line 1, in <module>
    from bgrm.bgrm import main
  File "/home/attila/.local/lib/python3.8/site-packages/bgrm/bgrm.py", line 10, in <module>
    from bgrm.settings import AppSettings
  File "/home/attila/.local/lib/python3.8/site-packages/bgrm/settings.py", line 9, in <module>
    class AppSettings:
  File "/home/attila/.local/lib/python3.8/site-packages/bgrm/settings.py", line 16, in AppSettings
    fill_color: tuple[float, float, float]
TypeError: 'type' object is not subscriptable

Any ideas?

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

At first glance, my guess is it would be some sort of version thing like maybe 'tuple' wasnt introduced as a type name for data classes yet or something, but I'm not sure.

I see python 3.8, but can you give me the full version name via python3.8 --version so I can try to reproduce and see if that's the issue?

from bgrm.

blueOkiris avatar blueOkiris commented on September 28, 2024

It appears to have been introduced in PEP 585, so I probably just need to manually import the Typing module if I want to support python 3.8

from bgrm.

athyla avatar athyla commented on September 28, 2024

Pfff... it seems that I have a mess on my machine.
Python3.8 version is: 3.8.15, but I also have python that defaults to version 2.7.18 and then I have python3 that defaults to python 3.10.8, but I also have python3.8 and 3.9, just to make things more complicated :(
pip was defaulting to python3.8, although the 3.9 and 3.10 versions are also installed.

It's a mess, I need to tidy it up.
Would it be okay to run bgrm with the latest python3? (3.10.8)
Edit1: Sorry, I went through the readme again, 3.10 is supported so I will keep only that :)

Edit2:
I have cleaned out python, now I have only python (2.7.18) and python3 (3.10.8) and installed pip for python3. I have also tried to reset my loopback devices and fake cams, so removed akvcam and all the v4l2loopback devices and recreated only one v4l2loopback device.
I also played around with the --camera option, but now that everything is cleaned up, the webcam id is 0, which should be the default.

So now bgrm works like a charm and it appears in the list of webcams, in Teams and Skype for example.

Just out of curiosity, would it be possible to make bgrm support a foreground, in addition to a background?
I'm thinking of a transparent png in the foreground, in front of the camera feed, showing for example a table, or a microphone stand, only partly covering the video feed. Would be a fun option to have xD

Thanks a lot for you assistance and for making bgrm, great work!

from bgrm.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.