ubantu中对blenderproc的研究系列(四)———模型对象背景替换

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"
      }
    }
  }
}
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值