The focus of this example is to introduce user to writer.CocoAnnotationsWriter
module.
Execute in the BlenderProc main directory:
python run.py examples/coco_annotations/config.yaml examples/coco_annotations/camera_positions examples/coco_annotations/scene.blend examples/coco_annotations/output
examples/coco_annotations/config.yaml
: path to the configuration file with pipeline configuration.examples/coco_annotations/camera_positions
: text file with parameters of camera positions.examples/coco_annotations/scene.blend
: path to the blend file with the basic scene.examples/coco_annotations/output
: path to the output directory.
You can use vis_coco_annotation.py with the following command to visualize the annotations blended over a rendered rgb image:
python scripts/vis_coco_annotation.py [-i <image index>] [-c <coco annotations json>] [-b <base folder of coco json and image files>]
With specific values:
python scripts/vis_coco_annotation.py -i 1 -c coco_annotations.json -b examples/coco_annotations/output/coco_data
Above are also the default values, i.e. for the same result call:
python scripts/vis_coco_annotation.py
- Loads
scene.blend
:loader.BlendLoader
module. TheBlendLoader
is used here as we always load thecp_category_id
for each object, which is stored in the.blend
file. - Creates a point light:
lighting.LightLoader
module. - Loads camera positions from
camera_positions
:camera.CameraLoader
module. - Renders rgb:
renderer.RgbRenderer
module. - Renders instance segmentation:
renderer.SegMapRenderer
module. - Writes coco annotations:
writer.CocoAnnotationsWriter
module.
{
"module": "renderer.SegMapRenderer",
"config": {
"map_by": ["instance", "class"],
}
},
The renderer.SegMapRenderer
needs to render both instance and class maps. The class is defined in terms of a custom property category_id
which must be previously defined for each instance. The category_id
can be either set in a custom Loader module or in a .blend
file.
{
"module": "writer.CocoAnnotationsWriter",
"config": {
}
}
This modules depends on output from renderer.SegMapRenderer
and stores annotations in coco_annotations.json
. Optionally, you can set "supercategory": "<some_supercategory>"
in the writer.CocoAnnotationsWriter
config to filter objects by a previously assigned custom property called "supercategory"
.
- suncg_basic: Rendering SUNCG scenes with fixed camera poses.
- suncg_with_cam_sampling: Rendering SUNCG scenes with dynamically sampled camera poses.