MatrixLens not computing lens properties on setting matrix

Hello,
[I am using Panda3d python APIs]
I have a physical camera’s intrinsic matrix that I am trying to mirror to a panda3d virtual camera. I came across a number of forums posts that indicated that in order to create a Lens with a custom projectionmatrix I have to use MatrixLens.setUserMat() and pass it my projection matrix. I created a projection matrix that is similar to an OpenGL projectionMatrix such as this:

camera_matrix = [focal_length_x 0 0 0
0 0 A 1
0 focal_length_y 0 0
0 0 B 0 ]

Where A = (zfar + znear) / (zfar - znear)
and B = -2 * znear*zfar / (zfar - znear)

matrix_lens = MatrixLens()
matrix_lens.setUserMat(camera_matrix)

On setting the projection matrix as such, I tried to query the parameters of the matrix such as:
matrix_lens.getAspectRatio()
matrix_lens.getFilmSize()
matrix_lens.getFocalLength()
matrix_lens.getFar()
matrix_lens.getNear()
matrix_lens.getFov()

However, the corresponding values that are returned do not seem to be computed from the projection matrix that was passed, so I get values that seem like defaults such as these:
Aspect Ratio: 1.0
Film Size: LVecBase2f(2, 2)
Focal Length: 1.0
Coordinate system: 0
Far: 100000.0
Near: 1.0
FOV: LVecBase2f(30, 30)
Keystone: LVecBase2f(0, 0)

If I query the projection matrix using matrix_lens.getProjectionMat() I get back the matrix that I passed in. I also find that the camera does not render the objects in the scene as intended.

My question (a) is why are the lens properties (such as FOV, aspectratio) not computed when I pass in a projection matrix? Do I have to call some other function to have Panda3D compute these values?

(b) In an OpenGL projection matrix I was also able to set the offsets to the principal point. How do we set the same in a panda3D projection matrix? When I set it as the corresponding fields C (x-coordinates) and D (y-coordinates) in the below matrix, the camera was no longer pointing at the scene I intended:

[ focal_length_x 0 C 0
0 0 A 1
0 focal_length_y D 0
0 0 B 0]

Thanks.

Panda isn’t able to compute lens properties from an arbitrary matrix, I believe. When you use a MatrixLens, the matrix you pass in is used, and the other lens parameters are ignored. Panda can compute from any other set of parameters, though, so you could just pass the focal length and near/far range to Panda and it will compute the other parameters accordingly.

In the case of MatrixLens, Panda computes the projection mat from these three components (in the monoscopic case):
completeProjMat = inverse(lensMat) * userMat * filmMat

The lens matrix transforms a point in front of the lens to a point in space, and is computed from setViewHpr or setViewVector, or overridden using setViewMat.
The film matrix is the post-projection transform and is computed from setFilmOffset and setFilmSize, and optional keystone. It can be overridden using setCustomFilmMat. Assuming I understand correctly what you mean by a principal point (I’m not at all knowledgeable in this area), setFilmOffset might be the place to apply the desired offset?