Definitely, it's a bug in the Rodrigues function...
If you read the corresponding doc, you may see that cv2.Rodrigues
has 2 different interfaces:
one that mimics the C++ interface, where the rotation vector (and optionaly the jacobian) are passed by reference and modified by the function
cv2.Rodrigues(src, dst[, jacobian]) --> None
and one (more Pythonic) where the rotation vector and the jacobian are returned as a tuple
cv2.Rodrigues(src) --> dst, jacobian
If you use the first interface, the pb vanishes...
import numpy as np
import cv2
def changes():
rmat=np.eye(4)
tvec=np.zeros(3)
#(rvec, jacobian)=cv2.Rodrigues(rmat)
cv2.Rodrigues(rmat, tvec)
print(tvec)
for i in range(2):
changes()
Result:
[0. 0. 0.]
[0. 0. 0.]
EDIT after further investigation:
The function is even more buggy as expected: when using the first interface, parameters dst
and jacobian
are not modified, which is in total contracdiction with the docstring:
>>> help(cv2.Rodrigues)
Help on built-in function Rodrigues:
Rodrigues(...)
Rodrigues(src[, dst[, jacobian]]) -> dst, jacobian
. @brief Converts a rotation matrix to a rotation vector or vice versa.
.
. @param src Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).
. @param dst Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively.
. @param jacobian Optional output Jacobian matrix, 3x9 or 9x3, which is a matrix of partial
. derivatives of the output array components with respect to the input array components.
In other words, this clearly requires a bug report...