Search code examples
blenderbounding-boxobject-detection

How to extract the bounding box of a model in Blender?


I am using Blender to render a model. The model is captured by the camera whose placement changes. Then I write the image to a file. How do I find the bounding box in the image so that this box can be used for annotation useful in training object detection models?


Solution

  • Every object in blender has a bound_box property, this is in simple axis min/max not an optimal rotated bounding box. Note that non-renderable objects will show a zero size bound_box, such as empty, camera, light, lattice, armature.

    Depending on the accuracy or time trade-offs you want to make, you can translate the points in the bound_box or each object vertex, to a rendered image co-ordinate as explained here. By translating each vertex you can create a region defining the outline of the object or you can just use min/max to create a simple bounding box to surround it.