0
$\begingroup$

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.

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

For the 8 bounding box corners in local coordinates:

ob.bound_box

Transformation matrix from local to global:

ob.matrix_world

Both together:

bbverts = [Vector(bbvert)*ob.matrix_world for bbvert in ob.bound_box]
| improve this answer | |
$\endgroup$
  • $\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 at 20:38

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