1
$\begingroup$

I am generating images from blender and also saving obj.location and obj.rotation_euler. After this, I want to plot the mesh of the object on the image generated based on the objects pose that I have saved. something like thisenter image description here

But I am not able to make sense of obj.location and obj.rotation_euler

x,y,z = 2.3005263805389404, 3.887678861618042, 0.505042314529419

3d rotation = -0.012391275726258755, -0.02587204799056053, 1.8222243785858154

which are plotting my object mesh outside the image. I noted down my blender camera position as

bpy.data.objects["Camera"].location = <Vector (11.5000, -10.0000, 8.0000)>

bpy.data.objects["Camera"].rotation_euler = <Euler (x=1.1093, y=0.0108, z=0.8149), order='XYZ'>

I am not sure how to proceed further.

$\endgroup$
5
  • $\begingroup$ Have a look to world_to_camera_view here docs.blender.org/api/current/… $\endgroup$
    – lemon
    Sep 29, 2020 at 9:03
  • $\begingroup$ world_to_camera_view takes in a 3D point. But in my case, I have a location and also orientation that needs to be transformed. And Also I wanted to perform this transform manual to get a better understanding. $\endgroup$
    – Guru Hegde
    Sep 29, 2020 at 9:17
  • $\begingroup$ objects have a "matrix_world" property. You can transform its vertices coordinates from local to world using it obj.matrix_world @ v.co $\endgroup$
    – lemon
    Sep 29, 2020 at 9:24
  • $\begingroup$ I think I must be trying to transform from world to local. As the blender obj location seems to be in the world. Right? $\endgroup$
    – Guru Hegde
    Sep 29, 2020 at 9:41
  • $\begingroup$ To plot (draw) on the rendered image, you should go from local to world then use world_to_camera_view. obj.location is world (if the object is not parented or constrained, etc) but its vertices coordinates are stored in local and you need them in world. $\endgroup$
    – lemon
    Sep 29, 2020 at 9:47

0

You must log in to answer this question.

Browse other questions tagged .