Сделать патч для blenderproc #5
Labels
No labels
construct
design
doc
feature
integration
programming
research
schematics
test
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: robossembler/nix-overlay#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Модуль для генерации датасетов Blenderproc работает с собственной версией Blender, которую подгружает в момент установки. Сама установка достаточно сложна (см. blenderproc/python/utility/SetupUtility.py).
Чтобы сделать blenderproc пакетом в nix, нужно разработать патч, который помощью переменной окружения (например,
USE_BPY
) пропускает сложную установку пакета в init-модуле, а использует python-модульbpy
, собранный в рамках этого оверлея. Соответственно, нужно передать для установки пути к python и bpy в /nix/store.Есть описание как можно сделать из blenderproc python модуль
https://github.com/DLR-RM/BlenderProc/issues/840#issuecomment-1484038029
You need to make sure you have python 3.10 as your interpreter to download bpy, and to download all python packages that BlenderProc needs. (You can look them up in the DefaultConfig.py file in the BlenderProc repo)
Then, do this steps:
Include the option of using bpy:
In the __ init __.py file in the blenderproc directory - I've introduced a new environment variable, called it "USING_BPY_PYTHON_MODULE", and when I include it in my python environment - I check for it first in the __ init __.py file - and import all of blenderproc API modules (copy lines 21-38)
Change if statement to elif in line 12 (now 32). The script would now check first for my environment variable, and then for the rest of blenderproc options.
In the Initializer.py script in the utility directory - include one more line of code in line 34 for setting the language.
if bpy.context.preferences.view.language: and put lines 34-36 under that if statement.
In bpy module, there are no languages that are loaded into the list above that blenderproc checks, so you need to check first if there are any languages in the list, and if there are - change it to English as blenderproc does. If not - ignore.
Lastly - you need to make sure you included your new env variable in the environment you are working on, and gave it a value.
Of course this is just a tweak. I do not guarantee that the code will be correct in all cases. It currently works well in the cases I tested.
Enjoy!
The code I included in the __ init __.py file:
if "USING_BPY_PYTHON_MODULE" in os.environ: from .api import loader from .api import utility from .api import sampler from .api import math from .python.utility.Initializer import init, clean_up from .api import postprocessing from .api import writer from .api import material from .api import lighting from .api import camera from .api import renderer from .api import world from .api import constructor from .api import types # pylint: disable=redefined-builtin from .api import object from .api import filter # pylint: enable=redefined-builtin
Для генерации датасета также нужны пакеты python:
numpy