Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Bigbiubang opened this issue Jan 5, 2025 · 1 comment
Open

Comments

@Bigbiubang
Copy link

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?

@Bigbiubang
Copy link
Author

hi! This is the result comparison.
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant