0
$\begingroup$

I have a computer vision task and I'm trying to generate synthetic data. I managed to output RGB and depth images from the camera, while also animating the camera to move around the scene.

In my processing, I obtain points in the camera coordinate system, and I want to transform them back into the world coordinate system.

To do this, I consider the matrix_world attribute of the camera, which if I'm not wrong represents a transformation matrix such that given a point p_w in the world coordinate system, the matrix product p_c = M_w * p_w where p_c is a point in the camera coordinate system.

For my task, I need to convert points in the camera reference system to points in the world coordinate system, so I simply invert the matrix_world of my camera and premultiply it with the point. This process happens for every frame in the animation, and the matrix I obtain from blender is almost always different between one frame and another.

Unfortunately, even though the target I'm tracking is static, the transformed points seem are moving in the world coordinate system... any idea of where I could be getting this wrong?

This is the code I use to extract the matrices

with open('C:\\Users\\HP\\Blender\\5\\camera_transform.csv', 'w') as f:
    mw = D.objects['Camera'].matrix_world
    f.write('frame_id, T11, T12, T13, T14, T21, T22, T23, T24, T31, T32, T33, T34, T41, T42, T43, T44\r\n')
    for frames in range(C.scene.frame_start, C.scene.frame_end+1):
        C.scene.frame_set(frames)
        out_list = []
        for x in mw:
            for y in x:
                out_list.append(y)
        output = "{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}\r\n".format(frames, *out_list)
        f.write(output)
$\endgroup$

0

You must log in to answer this question.

Browse other questions tagged .