Missing conversion of pyviso2 Matrix to Numpy array
chuong opened this issue · 3 comments
chuong commented
First thanks for this great interface.
I tried access elements of pyViso2's pose and motion matrices but only got error TypeError: 'Matrix' object does not support indexing
. Converting to numpy array using numpy.array() function produce a garbage array of the same size.
Is there a correct way to do this?
chuong commented
Sorry, converting to numpy array using numpy.array() function works as expected.
chuong commented
No, conversion using numpy.array() doesn't work as expected.
Then I came up with a work around solution using numpy.fromstring() function:
pose_np = np.fromstring(pose.__str__(), dtype=float, sep=' ').reshape([4,4])
est_motion_np = np.fromstring(est_motion.__str__(), dtype=float, sep=' ').reshape([4,4])
chuong commented
I found conversion function toNumpy() in viso2.i. So this is what works for me:
pose_np = np.zeros([4, 4])
est_motion_np = np.zeros([4, 4])
pose.toNumpy(pose_np)
est_motion.toNumpy(est_motion_np)