Closed xenogenesi closed 1 year ago
Hey there, thanks for all the info. I'll enable an option to use the users site packages soon and let you know.
Thanks, looking forward to it
@xenogenesi can you pull the current version from the main branch and give it a try? I'm a not sure if I should append the local user site packages by default to blenders sys path.. but for now it should do the trick.
Thanks, I see the UI now, when I try to use it to detect a pose from an mp4 video however Blender gets a SIGSEGV. It looks like a problem related to the opencv installation but I'm not sure. I tried the mediapipe python example for poses with the same video and it doesn't give me any problems (apart from that in some frames it doesn't resolve all the limbs)
@xenogenesi isn't python 3.10 the default version for blender 3.4? Please go in blenders scripting workspace and use the interactive console to check blenders python version and the site packages:
import sys
sys.executable
import site
site.getusersitepackages()
do the versions match?
next up, lets check if there any duplicate entries which might collide:
import subprocess
subprocess.run([sys.executable, "-m", "pip", "freeze"])
In the console window you'll see the installed packages. Does this only occur with videos or also when using a webcam (the behaviour should be the same). As it's a SIGSEGV there is prolly something pointing to NULL... will try to reproduce it but that may be tricky
I'm not expert but I think Blender is using the current selected system installation of Python (there could be multiple via update-alternative), something is changing though on Debian systems, after opening this issue, during a system upgrade got an email about pip (not clear to me if the changes are already in place, I installed some package with pip without venv and seems to work)
I'll do a test with a webcam and let you know. Thanks.
Whats catches my is:
opencv-contrib-python==4.7.0.68
opencv-python==4.7.0.68
opencv-python-headless==4.7.0.68
Usually you want just one of those in an environment. I can imagine that this can cause trouble. But I've been wondering why the mediapipe samples are running. As this is the case, could you try just running the holistic detection script from the add-on? BlendArMocap/src/cgt_mediapipe/cgt_mp_core/mp_holistic_detector.py
As local site packages can cause such behaviours I probably cannot link them by default. Guess they will only be linked in the future while "local user" is toggled.
However, usually you only want opencv-contrib-python==4.7.0.68
in your environment for mediapipe.
I haven't had the chance to try the cam yet, today I'll try.
The three packages installed are my fault, when I saw that cv had problems I did some "tests", but I confirm that the Mediapipe example for poses works, just did a quick test.
mp_holistic_detector.py:
% cd BlendArMocap-main/src/cgt_mediapipe/cgt_mp_core
% python3 mp_holistic_detector.py
Traceback (most recent call last):
File "/home/alex/.config/blender/3.4/scripts/addons/BlendArMocap-main/src/cgt_mediapipe/cgt_mp_core/mp_holistic_detector.py", line 3, in <module>
from . import cv_stream, mp_detector_node
ImportError: attempted relative import with no known parent package
I haven't had the chance to try the cam yet, today I'll try.
The three packages installed are my fault, when I saw that cv had problems I did some "tests", but I confirm that the Mediapipe example for poses works, just did a quick test.
mp_holistic_detector.py:
% cd BlendArMocap-main/src/cgt_mediapipe/cgt_mp_core % python3 mp_holistic_detector.py Traceback (most recent call last): File "/home/alex/.config/blender/3.4/scripts/addons/BlendArMocap-main/src/cgt_mediapipe/cgt_mp_core/mp_holistic_detector.py", line 3, in <module> from . import cv_stream, mp_detector_node ImportError: attempted relative import with no known parent package
That's just due to relative imports which are preferred for blender add-ons. You got to start the script using it's module path. Ensure to be in the BlendArMocap directory when executing the cmd.
python3 -m src.cgt_mediapipe.cgt_mp_core.mp_holistic_detector
% python3 -m src.cgt_mediapipe.cgt_mp_core.mp_holistic_detector
[ WARN:0@0.312] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video0): can't open camera by index
[ERROR:0@0.312] global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range
[ WARN:0@0.562] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video0): can't open camera by index
[ERROR:0@0.562] global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/alex/.config/blender/3.4/scripts/addons/BlendArMocap-main/src/cgt_mediapipe/cgt_mp_core/mp_holistic_detector.py", line 70, in <module>
detector = HolisticDetector(cv_stream.Stream(0))
^^^^^^^^^^^^^^^^^^^
File "/home/alex/.config/blender/3.4/scripts/addons/BlendArMocap-main/src/cgt_mediapipe/cgt_mp_core/cv_stream.py", line 30, in __init__
raise IOError("Cannot open webcam")
OSError: Cannot open webcam
With the cam it show a capture window for a second:
% python3 -m src.cgt_mediapipe.cgt_mp_core.mp_holistic_detector
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
With the cam and the Mediapipe pose example show the same capture window and works.
So I tried the plugin in blender, Movie and Cam, Face, Hands, Pose and Holistic, blender segv every time (same backtrace already posted)
Thanks for the support
Did you try removing the packages already?
> opencv-contrib-python==4.7.0.68
> opencv-python==4.7.0.68
> opencv-python-headless==4.7.0.68
I still can imagine that those are causing the issue, even though I'm confused that it seems to be running outside blender. Recommended for mediapipe is opencv-contrib-python==4.7.0.68
. In the stack trace it seems that opencv-python
is getting accessed.
Usually I'd recommend to uninstall via pip, but due to weird packaging that usually doesn't work properly. The easiest is to do it manually.
# navigate to your local site packages
cd /home/alex/.local/lib/python3.11/site-packages
# find cv entries
ls | grep cv
# move or remove them
rm -r opencv_contrib.......
rm -r cv2
# reinstall opencv-contrib (I usually use version opencv-contrib-python==4.5.5.64 but I'm not sure which is the best on ubuntu atm, without specifying you'll instal the newest version)
python3 -m pip install opencv-contrib-python
I removed the directories + uninstalled with pip (because pip freeze kept showing the 3 packages) and reinstalled the addon requirements with pip, which installed opencv-contrib-python==4.7.0.68, but blender kept crashing always with the same backtrace.
So, I uninstalled opencv-contrib-python and installed python3-opencv from debian, which installs cv2 '4.6.0', now "Detect" with a Movie seems to work, no crashes (my guess is that there's some binary incompatibility)
I'll do more in-depth tests of the addon as soon as I have time, if I have problems I'll let you know but as far as I'm concerned you can close this issue, if you want to do more tests to better understand the problem just let me know.
Thanks for the support and for the addon!
I did few more test, any version of opencv-contrib-python works as long as python3-opencv (cv2) is installed from the debian package, it even works without opencv-contrib-python (is installed only for its version of cv2?), version 4.5.5.64 alone crash as well.
I see in /proc/$(pidof blender)/maps
that the one installed by the system take precedence over opencv-contrib-python when installed (/usr/lib/python3/dist-packages/cv2.cpython-311-x86_64-linux-gnu.so
)
I did few more test, any version of opencv-contrib-python works as long as python3-opencv (cv2) is installed from the debian package, it even works without opencv-contrib-python (is installed only for its version of cv2?), version 4.5.5.64 alone crash as well.
I see in
/proc/$(pidof blender)/maps
that the one installed by the system take precedence over opencv-contrib-python when installed (/usr/lib/python3/dist-packages/cv2.cpython-311-x86_64-linux-gnu.so
)
thanks for all the infos! Sadly that's something which seems rly hard to integrate into the add-on. By now I've heard of different binary issues on linux. Often it boils down to trail and error. :/ Glad you got opencv running and to know that the debian package seems to help.
Hello
I would like to try the addon but I have dependency problems, the system is debian/sid, I don't intend to run blender with root privileges to install python packages (btw ensurepip is disabled in debian distros, I guess ubuntu too but I can't verify) so I installed them manually and the installation was successful, but the addon doesn't seem to find them.
Is there a way to bypass the checks or to check local installs as well?
The "main" branch behaves better than the last release, at least the UI appears, but the mediapipe tab contains instructions for installing the dependencies.
Thanks in advance