ubantu中对blenderproc的研究系列(四)———模型对象材质替换
过了个五一假期,继续blenderproc的学习!!!
为了争取在这一个系列结束后,可以实现仿真数据集的建立!我们掌握了光影,对象,摄像机设置,批量采样等方法后,我们以及可以成功的让一个建立的对象呈现出来。针对现在计算机视觉热点的工作集中在目标识别、分割等。我们可以利用对模型对象的背景替换,从而建立起一个计算机视觉的数据集。
首先看一下配置文件config.yaml
# Args: <obj_file> <path_to_textures> <output_dir>
{
"version": 3,
"setup": {
"blender_install_path": "/home_local/<env:USER>/blender/",
"pip": [
"h5py",
"imageio"
]
},
"modules": [
{
"module": "main.Initializer",
"config": {
"global": {
"output_dir": "<args:2>"
}
}
},
{
"module": "loader.ObjectLoader",
"config": {
"path": "<args:0>"
}
},
{
"module": "lighting.LightLoader",
"config": {
"lights": [
{
"type": "POINT",
"location": [5, -5, 5],
"energy": 0
}
]
}
},
{
"module": "camera.CameraLoader",
"config": {
"cam_poses": [
{
"location": [0, -13.741, 4.1242],
"rotation": {
"value":[1.3, 0, 0]
}
},
{
"location": [1.9488, -6.5202, 0.23291],
"rotation": {
"value": [1.84, 0, 0.5]
}
}
],
"intrinsics": {
"fov": 1
}
}
},
{
"module": "manipulators.MaterialManipulator",
"config": {
"selector": {
"provider": "getter.Material",
"conditions": {
"name": "Material.001"
}
},
"cf_color_link_to_displacement": 1.5
}
},
{
"module": "manipulators.MaterialManipulator",
"config": {
"selector": {
"provider": "getter.Material",
"conditions": {
"name": "Material.*"
}
},
"mode": "once_for_each",
"cf_textures": {
"Base Color": {
"provider": "sampler.Path",
"path": "<args:1>/*.jpg"
}
}
}
},
{
"module": "renderer.RgbRenderer",
"config": {
"output_key": "colors",
"samples": 350
}
},
{
"module": "writer.Hdf5Writer",
}
]
}
其中大部分模块我们前面都已经介绍过了,这里值的注意的是material.materialmanipulator模块。这个模块是根据条件选择材质并更改选定材质的某些参数:material.MaterialManipulator模块和getter.Material模块,它们允许我们根据用户定义的条件选择多个材质,并更改所选材质的属性值。
{
"module": "manipulators.MaterialManipulator",
"config": {
"selector": {
"provider": "getter.Material",
"conditions": {
"name": "Material.001"
}
},
"cf_color_link_to_displacement": 1.5
}
}
{
"module": "manipulators.MaterialManipulator",
"config": {
"selector": {
"provider": "getter.Material",
"conditions": {
"name": "Material.*"
}
},
"mode": "once_for_each",
"cf_textures": {
"Base Color": {
"provider": "sampler.Path",
"path": "<args:1>/*.jpg"
}
}
}
}