脚本必须在 Blender 自带 Python 环境中通过 blenderproc run 运行,不能直接用普通 python 解释器;IDE 断点调试需先在 Blender 环境装 debugpy 或 pydevd-pycharm 并做远程连接;debug 模式要求脚本位于当前工作目录
BlenderProc
DLR-RMGPL-3.0更新放缓用 Blender 程序化生成带深度、位姿等标注的逼真训练图像,解决计算机视觉任务缺高质量合成数据的问题。
A procedural Blender pipeline for photorealistic training image generation
pip install blenderproc
blenderproc quickstartREADME 未说明
用 Blender 程序化生成逼真训练图像与标注的渲染管线
用 Blender 程序化生成带深度、位姿等标注的逼真训练图像,解决计算机视觉任务缺高质量合成数据的问题。
核心能力
- 加载 obj、ply、blend、fbx 及 ShapeNet 等数据集
- 采样物体位姿并做物理仿真与碰撞检测
- 设置或采样 PBR 材质、灯光与相机位姿
- 渲染 RGB、立体、深度、法线与分割图
- 输出 hdf5 容器及 COCO、BOP 标注
容易踩的坑
- v2.7.2BlenderProc 2.7.2最新正式版2024-10-22 · 2024-10-22 13:59 UTC
- adds option back to use bop writer without multiprocessing (#1154)
- v.2.8.0BlenderProc 2.8.02024-10-22 · 2024-10-22 13:39 UTC
查看更新说明
- upgrades to blender 4.2.1 (#1136, thanks a lot to @Griperis who did the main work in this PR)
- updates default pip package-versions used inside blenderproc (#1110)
- adds support for loading collections from .blend files with intact hierarchies (#1149, thanks @johan-apes)
- adds support of quad faces to mesh_as_trimesh() function (#1127, thanks @MartinSmeyer)
- fixes memory leak in bvh tree creation (#1098, thanks @rasmushaugaard)
- fixes bproc.clean_up() to not reset render properties anymore (#1115)
- fixes CLI help text (#1125, thanks @Griperis)
- make sure object rotation is set in XYZ-Euler coordinates (#1142, thanks @tomole444)
- v2.7.1BlenderProc 2.7.12024-04-16 · 2024-04-16 09:02 UTC
查看更新说明
- new camera projection helper methods are available:
bproc.camera.depth_via_raytracing(),bproc.camera.pointcloud_from_depth(),bproc.camera.project_points(),bproc.camera.unproject_points()(#1045, #1075) - .blend loader now also supports hair_curves (#1052, thanks @sagoyal2)
- adds .usd loader (#1043, thanks @freLorbeer)
- fixes memory leak in bop writer (#1086, thanks @matteomastrogiuseppe)
- fixes removal of scene properties (#1055)
- fixes incorrect warnings regarding hidden objects in bop writer (#1058, thanks @saprrow)
- fixes linking objects when duplicating object hierarchy (#1081, thanks @AndreyYashkin)
- new camera projection helper methods are available:
- v2.7.0BlenderProc 2.7.02024-01-26 · 2024-01-26 16:27 UTC
查看更新说明
- upgrades to blender 3.5.1 (#788)
- adds helper methods for easy 3D-2D projection/unprojection, including
bproc.camera.depth_via_raytracing(),bproc.camera.pointcloud_from_depth(),bproc.camera.project_points(),bproc.camera.unproject_points(), see also point_cloud example (#1045) - removes support for obsolete .yaml configuration files (#962)
- speeds up bop writer for large number of objects - for 300 objects, the bop writer execution time reduces from 60s to 12s with 8 cores (#996)
- adds warning if hidden objects are given to bop writer (#998)
- skip transparent cc materials per default (#1004)
- rework of
duplicate(): allows linking and keeps parent relative transformation matrix (#1012, thanks @AndreyYashkin) - moves
hide()andis_hidden()to Entity class (#1015, thanks @AndreyYashkin) - fixes optical flow output key being overwritten by RGB (#963)
- fixes
--custom-blender-pathon windows (#972) - adapts downloading cc_textures to new naming scheme (#976, #993)
- fixes issue in light projector (#995, thanks @beekama)
- fixes skipping annotation indices when appending coco annotations (#1024)
- fixes frame offset in rendering progress bar (#1038, thanks @burcam)
- v2.6.2BlenderProc 2.6.22023-12-06 · 2023-12-06 20:08 UTC
查看更新说明
- Fixes blender download after changes on the blender.org website
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
BlenderProc2
A procedural Blender pipeline for photorealistic rendering.
Documentation | Tutorials | Examples | ArXiv paper | Workshop paper | JOSS article
Features
- Loading:
*.obj,*.ply,*.blend,*.fbx, BOP, ShapeNet, Haven, 3D-FRONT, etc. - Objects: Set or sample object poses, apply physics and collision checking.
- Materials: Set or sample physically-based materials and textures
- Lighting: Set or sample lights, automatic lighting of 3D-FRONT scenes.
- Cameras: Set, sample or load camera poses from file.
- Rendering: RGB, stereo, depth, normal and segmentation images/sequences.
- Writing: .hdf5 containers, COCO & BOP annotations.
Installation
Via pip
The simplest way to install blenderproc is via pip:
pip install blenderproc
Via git
Alternatively, if you need to make changes to blenderproc or you want to make use of the most recent version on the main-branch, clone the repository:
git clone https://github.com/DLR-RM/BlenderProc
To still make use of the blenderproc command and therefore use blenderproc anywhere on your system, make a local pip installation:
cd BlenderProc
pip install -e .
Usage
BlenderProc has to be run inside the blender python environment, as only there we can access the blender API. Therefore, instead of running your script with the usual python interpreter, the command line interface of BlenderProc has to be used.
blenderproc run <your_python_script>
In general, one run of your script first loads or constructs a 3D scene, then sets some camera poses inside this scene and renders different types of images (RGB, distance, semantic segmentation, etc.) for each of those camera poses. Usually, you will run your script multiple times, each time producing a new scene and rendering e.g. 5-20 images from it. With a little more experience, it is also possible to change scenes during a single script call, read here how this is done.
Quickstart
You can test your BlenderProc pip installation by running
blenderproc quickstart
This is an alias to blenderproc run quickstart.py where quickstart.py is:
import blenderproc as bproc
import numpy as np
bproc.init()
# Create a simple object:
obj = bproc.object.create_primitive("MONKEY")
# Create a point light next to it
light = bproc.types.Light()
light.set_location([2, -2, 0])
light.set_energy(300)
# Set the camera to be in front of the object
cam_pose = bproc.math.build_transformation_mat([0, -5, 0], [np.pi / 2, 0, 0])
bproc.camera.add_camera_pose(cam_pose)
# Render the scene
data = bproc.renderer.render()
# Write the rendering into an hdf5 file
bproc.writer.write_hdf5("output/", data)
BlenderProc creates the specified scene and renders the image into output/0.hdf5.
To visualize that image, simply call:
blenderproc vis hdf5 output/0.hdf5
Thats it! You rendered your first image with BlenderProc!
Debugging in the Blender GUI
To understand what is actually going on, BlenderProc has the great feature of visualizing everything inside the blender UI.
To do so, simply call your script with the debug instead of run subcommand:
blenderproc debug quickstart.py
Make sure that quickstart.py actually exists in your working directory.
Now the Blender UI opens up, the scripting tab is selected and the correct script is loaded.
To start the BlenderProc pipeline, one now just has to press Run BlenderProc (see red circle in image).
As in the normal mode, print statements are still printed to the terminal.
The pipeline can be run multiple times, as in the beginning of each run the scene is cleared.
Breakpoint-Debugging in IDEs
As blenderproc runs in blenders separate python environment, debugging your blenderproc script cannot be done in the same way as with any other python script. Therefore, remote debugging is necessary, which is explained for vscode and PyCharm in the following:
Debugging with vscode
First, install the debugpy package in blenders python environment.
blenderproc pip install debugpy
Now add the following configuration to your vscode launch.json.
{
"name": "Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
}
}
Finally, add the following lines to the top (after the imports) of your blenderproc script which you want to debug.
import debugpy
debugpy.listen(5678)
debugpy.wait_for_client()
Now run your blenderproc script as usual via the CLI and then start the added "Attach" configuration in vscode. You are now able to add breakpoints and go through the execution step by step.
Debugging with PyCharm Professional
In Pycharm, go to Edit configurations... and create a new configuration based on Python Debug Server.
The configuration will show you, specifically for your version, which pip package to install and which code to add into the script.
The following assumes Pycharm 2021.3:
First, install the pydevd-pycharm package in blenders python environment.
blenderproc pip install pydevd-pycharm~=212.5457.59
Now, add the following code to the top (after the imports) of your blenderproc script which you want to debug.
import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=12345, stdoutToServer=True, stderrToServer=True)
Then, first run your Python Debug Server configuration in PyCharm and then run your blenderproc script as usual via the CLI.
PyCharm should then go in debug mode, blocking the next code line.
You are now able to add breakpoints and go through the execution step by step.
What to do next?
As you now ran your first BlenderProc script, your ready to learn the basics:
Tutorials
Read through the tutorials, to get to know with the basic principles of how BlenderProc is used:
- Loading and manipulating objects
- Configuring the camera
- Rendering the scene
- Writing the results to file
- How key frames work
- Positioning objects via the physics simulator
Examples
We provide a lot of examples which explain all features in detail and should help you understand how BlenderProc works. Exploring our examples is the best way to learn about what you can do with BlenderProc. We also provide support for some datasets.
- Basic scene: Basic example, this is the ideal place to start for beginners
- Camera sampling: Sampling of different camera positions inside of a shape with constraints for the rotation.
- Object manipulation: Changing various parameters of objects.
- Material manipulation: Material selecting and manipulation.
- Physics positioning: Enabling simple simulated physical interactions between objects in the scene.
- Semantic segmentation: Generating semantic segmentation labels for a given scene.
- BOP Challenge: Generate the pose-annotated data used at the BOP Challenge 2020
- COCO annotations: Write COCO annotations to a .json file for selected objects in the scene.
and much more, see our examples for more details.
Contributions
Found a bug? help us by reporting it. Want a new feature in the next BlenderProc release? Create an issue. Made something useful or fixed a bug? Start a PR. Check the contributions guidelines.
Change log
See our change log.
Citation
If you use BlenderProc in a research project, please cite as follows:
@article{Denninger2023,
doi = {10.21105/joss.04901},
url = {https://doi.org/10.21105/joss.04901},
year = {2023},
publisher = {The Open Journal},
volume = {8},
number = {82},
pages = {4901},
author = {Maximilian Denninger and Dominik Winkelbauer and Martin Sundermeyer and Wout Boerdijk and Markus Knauer and Klaus H. Strobl and Matthias Humt and Rudolph Triebel},
title = {BlenderProc2: A Procedural Pipeline for Photorealistic Rendering},
journal = {Journal of Open Source Software}
}