Skip to content

Blender's Python script obtains camera pose issues through BPY API #223

@Bigbiubang

Description

@Bigbiubang

I have a complete model, and I render it using Blender's Python script to obtain the image and corresponding camera pose.
Then take the model (. ply) with the texture removed, the photo, and the corresponding camera pose as inputs. The prefix names of photos and camera pose files (. cam) correspond one-to-one.

Firstly, import the scene through BPY
Then obtain and set the camera:

camera = bpy.data.objects["Camera"]
camera.location = x, y, z
direction = - camera.location
rot_quat = direction.to_track_quat('-Z', 'Y')
camera.rotation_euler = rot_quat.to_euler()

Obtain camera pose:
RT = camera.matrix_world

R = RT[:3, :3]
T = RT[:3,3]

The. cam file consists of the following:
firstline: tx,ty,tz,r11,r12,r13,r21,r22,r23,r31,r32,r33
seconde line:

f = fx / width 
d0 = 0.
d1 = 0. 
paspect = fy / fx  
ppx = cx / width
ppy = cy / height

As mentioned above, the final result was very poor. I think it's a problem with the camera pose, that is, do we need other conversions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions