In this example we are demonstrating the sampling features in relation to camera objects.
Execute in the BlenderProc main directory:
python run.py examples/camera_sampling/config.yaml examples/camera_sampling/scene.obj examples/camera_sampling/output
examples/camera_sampling/config.yaml
: path to the configuration file with pipeline configuration.examples/camera_sampling/scene.obj
: path to the object file with the basic scene.examples/camera_sampling/output
: path to the output directory.
Visualize the generated data:
python scripts/visHdf5Files.py examples/camera_sampling/output/0.hdf5
- Loads
scene.obj
:loader.ObjectLoader
module. - Creates a point light:
lighting.LightLoader
module. - Samples camera positions randomly above the plane looking to the point of interest:
camera.CameraSampler
module. - Renders rgb, normals and distance:
renderer.RgbRenderer
module. - Writes the output to .hdf5 containers:
writer.Hdf5Writer
module.
{
"module": "camera.CameraSampler",
"config": {
"cam_poses": [
{
"number_of_samples": 5,
"location": {
"provider":"sampler.Uniform3d",
"max":[10, 10, 8],
"min":[-10, -10, 12]
},
"rotation": {
"format": "look_at",
"value": {
"provider": "getter.POI"
},
"inplane_rot": {
"provider": "sampler.Value",
"type": "float",
"min": -0.7854,
"max": 0.7854
}
}
}
]
}
}
The camera.CameraSampler
module allows sampling camera positions and orientations.
In this example, all camera poses are constrained to "look at" a point of interest (POI).
- Sample location uniformly in a bounding box above the plane.
For sampling camera positions we are using the sampler.Uniform3d Provider. To call a sampler for some attribute of a camera, specify a name (provider
) of a desired sampler and define some input arguments for it, e.g. min
and max
.
The sampler returns a value based on these input parameters specified in the config file, check the documentation for the samplers for more information on the input arguments, output formats, etc.
- Set orientation of the camera such that it will always look at the POI in any pose.
The getter.POI Provider also has a well-defined config structure, but here its output is fully dependent on the current state of the objects in the scene. The POI per default is defined as the object position closest to the mean position of all objects.
- Optionally, add an
"inplane_rot"
sampler to rotate the camera around the optical axis It samples float values between specifiedmin
andmax
in radians. Here it is used to randomly inplane rotate the cameras in an interval of +/- 45 degree.