Search code examples
point-cloud-librarypoint-clouds

Transformation of point cloud in PCL - understanding of transformation values


i downloaded scans of standford bunny from here

there is conf file, that contains transformations of scans, that looks like this:

camera -0.0172 -0.0936 -0.734 -0.0461723 0.970603 -0.235889 0.0124573 bmesh bun000.ply 0 0 0 0 0 0 1 bmesh bun045.ply -0.0520211 -0.000383981 -0.0109223 0.00548449 -0.294635 -0.0038555 0.955586

what i want to do is to get these 2 scans into the same coordinate system using point cloud library, but i don't understand values of these transformations

i found tutorials on 4x4 matrix transformations, is it possible to create 4x4 matrix from these values? or is this something completely different?


Solution

  • I'm not sure about my answer, judging from the format I think it's position_x position_y position_z quaternion_x quaternion_y quaternion_z quaternion_w but please check with the code provided below

    from transforms3d.quaternions import quat2mat   
    import numpy as np
    
    # Create Identity transformation for 4x4
    T = np.eye(4)
    
    # Caution quat2mat uses w, x, y, z! Need to reorder your quaternion
    T[:3, :3] = quat2mat([0.0124573, -0.0461723, 0.970603, -0.235889])
    
    # Insert position x, y, z
    T[:3, 3] = [-0.0172, -0.0936, -0.734]
    
    # Print Result
    print(T)                                                                     
    # [[-0.99542587 -0.08375279  0.04596522 -0.0172    ]
    #  [-0.09550694  0.8844491  -0.45675838 -0.0936    ]
    #  [-0.00239911 -0.45905911 -0.88840249 -0.734     ]
    #  [ 0.          0.          0.          1.        ]]