Segmentation fault using OpenCV (probably QT related) #128689

Open
opened 2024-10-07 12:51:56 +02:00 by Robert-Bohdal · 8 comments

System Information
Operating system: ManjaroLinux 24.1.0, kernel 6.6.52-1-MANJARO
Graphics card: NVIDIA GeForce GTX 1070

Blender Version
Broken: (3.4 and newer)
Worked: (3.3 and older)

Short description of error
Blender from the official Blender project repository crashes when displaying opencv window.

Exact steps for others to reproduce the error
Open included BlenderTestOpenCV.blend and run script
or run included python script via commandline:
blender -P BlenderTestOpenCV.py

BTW: Manjaro compiled Blender 4.2.1 installed via package manager from Manjaro reposiroty works without problems, but only with python and its modules installed via package manager (in my case python version 3.12.5) not via pip.
I haven't experienced this problem on Windows OS.

**System Information** Operating system: ManjaroLinux 24.1.0, kernel 6.6.52-1-MANJARO Graphics card: NVIDIA GeForce GTX 1070 **Blender Version** Broken: (3.4 and newer) Worked: (3.3 and older) **Short description of error** Blender from the official Blender project repository crashes when displaying opencv window. **Exact steps for others to reproduce the error** Open included BlenderTestOpenCV.blend and run script or run included python script via commandline: blender -P BlenderTestOpenCV.py BTW: **Manjaro compiled Blender** 4.2.1 installed via package manager from Manjaro reposiroty **works without problems**, but only with python and its modules installed via package manager (in my case python version 3.12.5) **not via pip**. I haven't experienced this problem on Windows OS.
Robert-Bohdal added the
Status
Needs Triage
Severity
Normal
Type
Bug
labels 2024-10-07 12:51:57 +02:00
Member

Hi! It's likely a python version mismatch. Blender officially bundles with Python 3.11, and on linux, some package managers installs blender with system python, which will have different version (in this case 3.12). So if you have found the combination that works for you, then you can keep it that way.

I do not think this is a bug with Blender particularly, it's only on linux we allow this kind of version discrepancy since it may match the logic of a lot of programs in linux. This made it a bit more inconvenient for people who wasn't aware the difference.

Hi! It's likely a python version mismatch. Blender officially bundles with Python 3.11, and on linux, some package managers installs blender with system python, which will have different version (in this case 3.12). So if you have found the combination that works for you, then you can keep it that way. I do not think this is a bug with Blender particularly, it's only on linux we allow this kind of version discrepancy since it may match the logic of a lot of programs in linux. This made it a bit more inconvenient for people who wasn't aware the difference.
Author

Hi! It's likely a python version mismatch

I don't know if this problem is caused by a python version mismatch. I tried really many combinations of running official Blender (--python-use-system-env) with different versions of python 3.11.7, 3.12.5 (with venv and with versions installed using package manager) with BLENDER_SYSTEM_PYTHON, PYTHONPATH set correctly. Blender itself works, but it doesn't work with the OpenCV window. I have also tried Blender compiled in Manjaro with user-installed Python (venv), but even this combination does not work satisfactorily. I found one discrepancy between the opencv-python module compiled in Manjaro (uses Qt6) and pip opencv-python (uses Qt5).

I do not think this is a bug with Blender particularly.

Hard to say without a better understanding. OpenCV team couldn't help with this.

So if you have found the combination that works for you, then you can keep it that way.

Unfortunately this didn't solve the problem for me, because I also need to use the mediapipe module, but I can't install it via pip, I have to compile it and also other modules which depend on OpenCV.

I have one question, what changed from Blender version 3.3 to 3.4 that 3.3 works but 3.4 doesn't?

> Hi! It's likely a python version mismatch I don't know if this problem is caused by a python version mismatch. I tried really many combinations of running official Blender (--python-use-system-env) with different versions of python 3.11.7, 3.12.5 (with venv and with versions installed using package manager) with BLENDER_SYSTEM_PYTHON, PYTHONPATH set correctly. Blender itself works, but it doesn't work with the OpenCV window. I have also tried Blender compiled in Manjaro with user-installed Python (venv), but even this combination does not work satisfactorily. I found one discrepancy between the opencv-python module compiled in Manjaro (uses Qt6) and pip opencv-python (uses Qt5). > I do not think this is a bug with Blender particularly. Hard to say without a better understanding. OpenCV team couldn't help with this. >So if you have found the combination that works for you, then you can keep it that way. Unfortunately this didn't solve the problem for me, because I also need to use the **mediapipe** module, but I can't install it via pip, I have to compile it and also other modules which depend on OpenCV. I have one question, what changed from Blender version 3.3 to 3.4 that 3.3 works but 3.4 doesn't?
Member

I have one question, what changed from Blender version 3.3 to 3.4 that 3.3 works but 3.4 doesn't?

We did bump python version to 3.11 in Blender 3.4, I guess that's why it broke for you.

Current 4.4 main is on python 3.11.9. If you do have other dependencies that you can't acquire by installing via pip, you may consider compiling all those 3rd party libraries yourself against this exact python version. If you want to use system python (and you can make sure those people who use your tool sets also are on the same system python version, then you could try compiling against that version as well.

> I have one question, what changed from Blender version 3.3 to 3.4 that 3.3 works but 3.4 doesn't? We did bump python version to 3.11 in Blender 3.4, I guess that's why it broke for you. Current 4.4 `main` is on python 3.11.9. If you do have other dependencies that you can't acquire by installing via `pip`, you may consider compiling all those 3rd party libraries yourself against this exact python version. If you want to use system python (and you can make sure those people who use your tool sets also are on the same system python version, then you could try compiling against that version as well.
Author

Am I to understand that any Linux user who wants to use Blender from the official repository and also use the OpenCV module to display a window must compile all Python modules that depend on OpenCV?

Personally, I've tried two "popular" Linux distributions (Manjaro, Ubuntu) and I couldn't run the script in either without Blender crashing. Another user also has this problem, but still no clear cause has been found. Please take a look here as well here.

If you find that the simple script attached above works in your Linux or Blender does not crash on the python command cv2.namedWindow('xxx') , please post your Linux distribution here so I can install it and not have to develop an add-on in Windows OS. Thank you very much.

Am I to understand that any Linux user who wants to use Blender from the official repository and also use the OpenCV module to display a window must compile all Python modules that depend on OpenCV? Personally, I've tried two "popular" Linux distributions (Manjaro, Ubuntu) and I couldn't run the script in either without Blender crashing. Another user also has [this problem](https://projects.blender.org/blender/blender/issues/110842), but still no clear cause has been found. Please take a look here as well [here](https://github.com/opencv/opencv/issues/24161). If you find that the simple script attached above works in your Linux or Blender does not crash on the python command cv2.namedWindow('xxx') , please post your Linux distribution here so I can install it and not have to develop an add-on in Windows OS. Thank you very much.
Member

Also a bit confused about the python version mismatch (that command uses sys.executable, if I use a self-compiled blender, that should be 3.11, isnt pip supposed to grab the right libs then?)

for a self-compiled blender, cv2 and opencv_python.libs end up in
/path/to/builddirectory/bin/4.4/python/lib/python3.11/site-packages

for a blender downloaded from blender.org (or a blender installed via snap), cv2 and opencv_python.libs end up in
~/.local/lib/python3.11/site-packages

I found one discrepancy between the opencv-python module compiled in Manjaro (uses Qt6) and pip opencv-python (uses Qt5).

can confirm that what pip fetches uses QT5 (libQt5Core, libQt5X, libQt5Gui, ...)

Also a bit confused about the python version mismatch (that command uses `sys.executable`, if I use a self-compiled blender, that should be 3.11, isnt pip supposed to grab the right libs then?) for a self-compiled blender, `cv2` and `opencv_python.libs` end up in `/path/to/builddirectory/bin/4.4/python/lib/python3.11/site-packages` for a blender downloaded from blender.org (or a blender installed via snap), `cv2` and `opencv_python.libs` end up in `~/.local/lib/python3.11/site-packages` >I found one discrepancy between the opencv-python module compiled in Manjaro (uses Qt6) and pip opencv-python (uses Qt5). can confirm that what pip fetches uses QT5 (libQt5Core, libQt5X, libQt5Gui, ...)
Member

if I use a self-compiled blender, that should be 3.11

On linux there's an option to compile blender use system python instead of bundled python, so it's not guaranteed that you will get the 3.11 when you self-compile. Especially in a lot of distros blender package is handled like that.

> if I use a self-compiled blender, that should be 3.11 On linux there's an option to compile blender use system python instead of bundled python, so it's not guaranteed that you will get the 3.11 when you self-compile. Especially in a lot of distros blender package is handled like that.
Member

if I use a self-compiled blender, that should be 3.11

On linux there's an option to compile blender use system python instead of bundled python, so it's not guaranteed that you will get the 3.11 when you self-compile. Especially in a lot of distros blender package is handled like that.

OK, but in my case it is 3.11 -- and the result is still crashes

> > if I use a self-compiled blender, that should be 3.11 > > On linux there's an option to compile blender use system python instead of bundled python, so it's not guaranteed that you will get the 3.11 when you self-compile. Especially in a lot of distros blender package is handled like that. OK, but in my case it is 3.11 -- and the result is still crashes
Member

Not sure about the way blender should support this usage of QT/OpenCv (and being aware that the back-trace doesn't point to Blender's code), I will still confirm this since this was working fine in 3.3 (can be taken back or closed if considered outside of Blender's realm).

Not sure about the way blender should support this usage of QT/OpenCv (and being aware that the back-trace doesn't point to Blender's code), I will still confirm this since this was working fine in 3.3 (can be taken back or closed if considered outside of Blender's realm).
Philipp Oeser added
Module
Python API
Interest
User Interface
Status
Confirmed
and removed
Status
Needs Triage
labels 2024-10-08 12:51:20 +02:00
Philipp Oeser changed title from Segmentation fault using OpenCV to Segmentation fault using OpenCV (probably QT related) 2024-10-08 12:51:41 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#128689
No description provided.