I have a vehicle model, the 3D bounding box of the vehicle model contains the 3D coordinates of each vertex. My question is would it possible to get the 3D bounding box coordinates, which is a 8 vertex vector [8,2] directly from python. With this bounding box coordinates, I want to do two things, firstly calculate the pose of the object, secondly find a way to calculate the image pixel coordinate corresponding to each 3D vertex.

I have found some related work, this Save the 2D bounding box of an object in rendered image to a text file shows how to get 2D bounding box coordinates around the image, however it is 2D bounding box. Furthermore, Display bounding box around objects can show us how to display the 3D bounding box around the object, it doesn't tell me how to get vertex in python.

  • $\begingroup$ you may be interested in the addon made for this answer. $\endgroup$
    – sambler
    Aug 26 '17 at 6:21

For the 8 bounding box corners in local coordinates:


Transformation matrix from local to global:


Both together:

bbverts = [ob.matrix_world * Vector(bbvert) for bbvert in ob.bound_box]


bbverts = [ob.matrix_world @ Vector(bbvert) for bbvert in ob.bound_box]

for versions 2.8 and above.

  • $\begingroup$ what I mean is not the x,y,z of the object, but the coordinates of 3D bounding box, which is a 16 elements array of 8 vertex at the corners of the object $\endgroup$
    – user824624
    Aug 25 '17 at 21:42
  • $\begingroup$ I have edited the answer. It is a duplicate of blender.stackexchange.com/questions/8459/…. $\endgroup$
    – Dimali
    Aug 25 '17 at 21:51
  • $\begingroup$ Should this not be ob.matrix_world * Vector(bbvert)? (@ instead of * in newer versions) $\endgroup$
    – Nathan
    Jan 25 '20 at 20:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.