Open benjiebob opened 2 years ago
A bit late to the party, but what worked for me was inverting rows 1 & 2 then inverting the whole camera_pose
(which indeed transposes R
like you tried, but it also corrects t
for the new R
).
In short -
camera_pose[[1, 2]] *= -1
camera_pose = np.linalg.inv(camera_pose)
Hi! I also tried a few days to get the correct pyrender camera pose, and I find this problem is maybe caused by the flipped y and z axis in pyrender, so you should flip the translation and rotation angles on the y and z axis, I posted an example here: https://github.com/mmatl/pyrender/issues/249
A bit late to the party, but what worked for me was inverting rows 1 & 2 then inverting the whole
camera_pose
(which indeed transposesR
like you tried, but it also correctt
for the newR
).In short -
camera_pose[[1, 2]] *= -1 camera_pose = np.linalg.inv(camera_pose)
Thanks! This solution also works for me.
Hi,
The transformation works. Can I please know the intuition behind the inversion of the camera_pose?
camera_pose[[1, 2]] *= -1
camera_pose = np.linalg.inv(camera_pose)
Hey @Chris10M , I found this by a bit of trial and error, but the intuition generally is that OP mentioned transposing R
due to pre- vs post- multiplication of the transformation matrix, and I felt like t
ought to be adjusted to the transposed rotation matrix.
My guess is this:
RT_pyrender = RT_opencv
RT_pyrender[[1, 2]] *= -1
camera_pose = np.linalg.inv(RT_pyrender)
Hi there, excellent library. I've been banging my head against the wall for a few days now with this problem so thought it might be a good time to beg for help! :)
I have a
camera_matrix
and run OpenCV'scv2.solvePnP(points3d, points2d, camera_matrix, distCoeffs=None)
to obtain extrinsicsR
,t
. Using similar code to this, I can render my SMPL mesh vertices and it looks fine (see Fig A)For debugging purposes, I've loaded these parameters into Pytorch3D, using their
cameras_from_opencv_projection(R, t, camera_matrix, image_size)
, method and am able to correctly render the mesh (see Fig B)Now is where the fun begins...
I've been trying for a few days to figure out how to render this mesh correctly using Pyrender. I've constructed a rendering function (similar to this one):
Based on this answer, I've tried:
R
&t
(see Fig C).As you can see, the Pyrender mesh still doesn't line up with the others.
From here, I've tried a whole bunch of things including fiddling with the principle point, starting with the PyTorch3D matrix and rotating 180 through X (as suggested here) but nothing has worked.
I'd be super grateful if someone could help me solve this. In case helpful, see the following descriptions for the camera setup in each of the libraries:
Thanks! Ben