I have successfully calibrated a camera using this link:
openCV camera Calibration
I get the camera matrix, distortion coefficients, rotation vectors (rvects) and translation vectors (tvects). However, the rvects and tvects are a long list of arrays and I would like the rotation matrix and transformation matrix instead.
How would I go about converting the rvects array to a rotation matrix and the tvects array to a transformation matrix?
I found that it could be done using ‘Rodrigues’ but I am unsure exactly how this is done. Some clarification would be great, thanks.
Below is the data after running the camera calibration using OpenCV:
Camera matrix :
[[1.44644326e+03 0.00000000e+00 9.59836634e+02]
[0.00000000e+00 1.44646498e+03 5.39556895e+02]
[0.00000000e+00 0.00000000e+00 1.00000000e+00]]
dist :
[[ 6.95929106e-06 -2.00836991e-04 8.42048176e-06 2.98005924e-05
3.04891387e-04]]
rvecs :
[array([[0.10322433],
[0.00586084],
[0.01965572]]), array([[ 0.02876875],
[-0.03474045],
[ 0.01824509]]), array([[ 0.03467534],
[-0.05020887],
[ 0.01830534]]), array([[ 0.03556834],
[-0.05399128],
[-0.0484105 ]]), array([[ 0.03717584],
[ 0.08012789],
[-0.04607123]]), array([[ 0.01846599],
[-0.11597159],
[-0.05320749]]), array([[ 0.10165191],
[-0.07348809],
[ 0.02913424]]), array([[-0.05693991],
[-0.011658 ],
[ 0.01366273]]), array([[ 0.30802603],
[-0.10069939],
[ 0.10513563]]), array([[0.0610907 ],
[0.44109706],
[0.11019328]]), array([[-0.19697588],
[-0.04283537],
[ 0.03067312]])
...
...
...
tvecs :
[array([[ 2.66476989],
[-3.33673936],
[17.85376573]]), array([[-4.8351615 ],
[ 0.55764164],
[18.24433871]]), array([[-9.69708746],
[-4.47578088],
[16.45470293]]), array([[-10.84578967],
[ -7.83191025],
[ 25.7312514 ]]), array([[ 8.33363135],
[-4.864706 ],
[27.99576755]]), array([[-8.31158562],
[ 0.06787774],
[23.34155579]]), array([[-11.63857256],
[ 2.74490915],
[ 23.75431658]]), array([[-0.70765791],
[ 3.80631702],
[28.47027191]]), array([[-14.7612401],
[ -0.32354 ],
[ 25.6419018]])
...
...
...
Below is the desired data (condensed matrix instead of rvects and tvects for each frame)
[
{
'id': 3, // optional
'R': [ /* 3x3 rotation matrix */ ],
'k': [ /* 3x3 calibration/instrinsics matrix */ ],
't': [ /* 3x1 translation matrix */ ],
'dist': [ /* 5x1 distortion coefficients */ ]
}.
]