cgtinker / BlendArMocap

realtime motion tracking in blender using mediapipe and rigify
GNU General Public License v3.0
929 stars 112 forks source link

Segmentation fault on Manjaro Linux with Mediapipe #150

Open Tanza3D opened 1 year ago

Tanza3D commented 1 year ago

Describe the bug Blender completely segfaults out, regardless of what tracking type is being used, and if it's a webcam or mp4 file. I've installed the dependencies manually and used the button through sudo, and they all show up.

To Reproduce Steps to reproduce the behavior:

  1. Open Blender
  2. Attempt to track Webcam or import video file through BlendArMocap plugin with MediaPipe

Logs Logs are from 3.5.0, as that's the only one which saves blender-crash.txt. For whatever reason, 3.6.0 seems to segfault so hard it never seems to get the chance to do so.

INFO:root:PoseDetector -> PoseRotationCalculator -> MPPoseOutputNode
04-08 00:12:45 - BlendArMocap: INFO - PoseDetector -> PoseRotationCalculator -> MPPoseOutputNode - cgt_mp_detection_operator.py:62
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Writing: /tmp/blender.crash.txt
zsh: segmentation fault (core dumped)  ./blender
# Blender 3.5.0, Commit date: 2023-02-14 21:21, Hash dcc80748d327
bpy.ops.simpletabs.update()  # Operator
Cannot read file '/home/tanza/Downloads/Drgn21-16_collection_KmiBvis.blend': No such file or directory  # Error
bpy.ops.view3d.blenderkit_disclaimer_widget(message="Don't miss your chance. Only a few days left. Keep lower price forever.", url="https://www.blenderkit.com/articles/price-increase/", fadeout_time=8, tip=False)  # Operator
bpy.context.space_data.system_bookmarks_active = 3  # Property
bpy.context.space_data.params.filter_search = "art"  # Property
bpy.context.space_data.params.filter_search = "blendar"  # Property
Modules Installed (BlendArMocap) from '/home/tanza/Downloads/BlendArMocap_release_160.zip' into '/home/tanza/.config/blender/3.5/scripts/addons'  # Info
bpy.ops.button.cgt_install_dependencies()  # Operator
bpy.context.space_data.system_bookmarks_active = 6  # Property
bpy.context.scene.cgtinker_mediapipe.enum_detection_type = 'HOLISTIC'  # Property
bpy.context.scene.cgtinker_mediapipe.enum_detection_type = 'POSE'  # Property
Running POSE as modal.  # Info

# backtrace

# Python backtrace

Desktop (please complete the following information):

Tanza3D commented 1 year ago

I have my own tracking software which routes into Unity which uses OpenCV and Mediapipe and although different versions of both Python and those two packages, it works fine, so I don't think it's a misconfiguration with my system atleast, although maybe I've made a mistake with the install on Blender.

cgtinker commented 1 year ago

Did you start blender via the terminal? Did you try detecting in a .mov?

Unix sys and camera permissions can be an issue..

Tanza3D commented 1 year ago

Trying a .mov file has the same issue as with the mp4 or the camera. I've been running it through the terminal, although trying to detect with blender running as sudo and also trying to detect when running blender from the start menu both also crash. The first log I attached is copied from the terminal as I ran. I've also tried adjusting the permissions of the files but that hasn't helped.

cgtinker commented 1 year ago

Don't really know what's going on, maybe the dependency is corrupted. Can you run "pip freeze" within blender or via blenders python executable?

Also, I'm working on a separate exe to pipe the data to blender in the future, maybe you want to join? If so, let me know, currently thinking on how to setup the inter process communication =) https://github.com/cgtinker/BlendArMocapWrapper

Tanza3D commented 1 year ago

seems like the opencv-contrib-python version was too new...

absl-py==1.4.0
aiohttp==3.8.4
aiosignal==1.3.1
async-timeout==4.0.2
attrs==22.2.0
autopep8==1.6.0
Brotli==1.0.9
certifi==2021.10.8
charset-normalizer==3.1.0
colorama==0.4.6
contourpy==1.0.7
cycler==0.11.0
Cython==0.29.30
discum==1.4.1
filetype==1.2.0
flatbuffers==23.3.3
fonttools==4.39.3
frozenlist==1.3.3
idna==3.3
kiwisolver==1.4.4
lottie==0.7.0
matplotlib==3.7.1
mediapipe==0.8.10
multidict==6.0.4
numpy==1.24.2
openai==0.27.2
opencv-contrib-python==4.7.0.72
opencv-python==4.7.0.72
packaging==23.0
Pillow==9.4.0
protobuf==3.20.3
pycodestyle==2.8.0
pyparsing==3.0.9
python-dateutil==2.8.2
requests==2.27.1
requests-toolbelt==0.10.1
six==1.16.0
toml==0.10.2
tqdm==4.65.0
ua-parser==0.16.1
urllib3==1.26.8
websocket-client==0.59.0
yarl==1.8.2
zstandard==0.16.0

but the version on the wiki doesn't seem to exist?

ERROR: Could not find a version that satisfies the requirement opencv-contrib-python==4.2.0.34 (from versions: 3.4.11.45, 3.4.13.47, 3.4.14.51, 3.4.15.55, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.4.0.46, 4.5.1.48, 4.5.2.52, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66, 4.7.0.68, 4.7.0.72)
ERROR: No matching distribution found for opencv-contrib-python==4.2.0.34

also definitely sounds interesting but don't have any time really, might get around to contributing something in the future to that though! definitely seems like a better way to go about this than integrating it directly into blender lol

cgtinker commented 1 year ago

opencv-contrib-python==4.7.0.72 opencv-python==4.7.0.72

having two opencv versions available can also lead to issues. When there have been issues with opencv often the best way is to install opencv via the local package manager (remove blenders pip opencv versions before)..

yea the internal dependencies are really annoying. especially as they can clash with other add-on dependencies and python versions..

Tanza3D commented 1 year ago

ohh i didn't notice there were two. the other one might've come from something i was working on locally :sweat_smile: i uninstalled it (opencv-python) but seems to still lead to the crash :/

Tanza3D commented 1 year ago

also tried uninstalling the other opencv through blender's python and installing it locally myself, still nothing :(

Vidyut commented 1 year ago

Did you find the solution? I'm having the same issue on a Ubuntu LTS

image

It recognises the dependencies as already available, but Blender crashes if I try to use BlendArMocap.

Vidyut commented 1 year ago

The only thing I can think of is a python version/compatibility issue. The console says PYTHON INTERACTIVE CONSOLE 3.10.9 but the python on my system is 3.10.6. It is true that I have the packages already installed, but I'm not sure this is how it is supposed to be, though I also read somewhere that blender will import modules it needs if they are installed.

Just describing all this in case it helps someone cleverer to pinpoint the issue.

Some clarity on this too would be good, since the instructions insist that higher permissions are needed, but the addon recognises modules installed locally with lower permissions.

Anyway, on the off-chance that it needed to be done via sudo even if the modules were present, I did as the instructions said. The install failed. BTW, for someone non-technical like me, this is terrifying.

I tried to install it directly to the python folder, and it said I lacked permissions. I could try to force the issue with sudo, but given how this thing is going, chances are I'll break something important.

So now what. I have only one opencv, not two, so maybe that isn't the issue. The opencv-contrib-python is 4.6.0.66 (so not too new), then I upgraded opencv. Also crash. So the version doesn't seem to be the issue either. Besides, the newer versions break freemocap's dependency, and given that we're expecting to use freemocap, this can't be the answer, I guess.

Now what.

Only possibility remaining to test seems to be a downloaded blender - it shouldn't need anything it doesn't have permissions for as an ordinary folder... Will try it and update here.

Tanza3D commented 1 year ago

hi, afraid not, the issue still occurs for me sadly. also, i use blender downloaded and extracted directly, no package manager or anything, though it might be worth trying an environment like snap or flatpak, i'll try this now

Tanza3D commented 1 year ago

no luck through flatpak nor snap

Vidyut commented 1 year ago

Some progress from blender's scripting console.

image

If the libraries can be imported, perhaps may be useful to try importing them rather than installing?

Vidyut commented 1 year ago

I was able to install dependencies for dream-textures by going to the addon folder and typing:

/snap/blender/3915/3.6/python/bin/python3.10 -m pip install -r requirements/mac-mps-cpu.txt --target .python_dependencies

As per instructions for installing from source for linux here https://github.com/carson-katri/dream-textures/blob/main/docs/SETUP.md

No higher permissions needed.

Something similar could be done for BlendArMocap? I think specifying the target in the addon folder (as opposed to anything needing elevated permissions) seemed to do the trick.

Tanza3D commented 11 months ago

noticed something new today, when you run motion detection on a clip, blender very quickly uses up all the disk space before it crashes, i think that'd be something to do with it?

https://github.com/cgtinker/BlendArMocap/assets/33783503/a51e27f6-fa2c-481f-a457-860deddc9b8d