0

I have obtained a camera matrix by establishing correspondences between 3D points in space with 2D points on a screen (resectioning)

My custom matrix seems to be working, but I am not being able to apply this matrix to a Unity main camera the same way I was doing on another application. For Unity, it seems I need to decompose my matrix in order to obtain position, orientation, and FOV, etc.

I have seen many topics about using custom matrices on Unity Main Camera but in all cases they had a projection matrix separated from the camera model matrix.

this is the math behind my process to obtain my custom matrix: https://math.stackexchange.com/questions/3388529/resectioning-problem-and-matrix-decomposition-what-am-i-missing>

Here I am using one specific application (Unity) but I would be glad to understand the math behind it anyway.

I have made a sketch on Processing to test my code, where I can simply use my custom matrix to override the default matrix by:

pushMatrix();
applyMatrix(customViewProjMatrix);
shape(model3d, 0, 0);  //this is what I want to render
popMatrix();

Now, my matrix is the product of the View and Projection matrices so I couldn't find a way to use this on Unity main camera, as it seems I need them to be two different things.

Still in Unity, similarly as the code above, I can create some debugging lines via creating some custom shader.

GL.PushMatrix();
GL.LoadPixelMatrix ();
GL.MultMatrix (customViewProjMatrix);
GL.Color(Color.yellow);
GL.Begin(GL.LINES);
GL.Vertex3 (-5f, 5f, -5f);
GL.Vertex3 (-5f, -5f, -5f);
GL.End();
GL.PopMatrix();

This is just for checking my matrix, but doesn't affect the main camera, which is my goal.

I am not if I can use my matrix the way I obtain it on Unity, so any suggestions on how to use my custom matrix or another method for creating it to be used on unity would be appreciated.

Bontempos
  • 77
  • 8
  • It does appear to be pretty simple math: https://stackoverflow.com/questions/39992968/how-to-calculate-field-of-view-of-the-camera-from-camera-intrinsic-matrix Simply reusing the calibrationMatrixValues implementation in OpenCV should work perfectly fine. – Lou Garczynski Oct 26 '19 at 09:57
  • the link you refer is not teaching me how to get the extrinsic parameters from my custom matrix, right? – Bontempos Oct 26 '19 at 18:47
  • The answer contains multiple links that refer to your problem, extracting camera parameters from the camera matrix – Lou Garczynski Nov 05 '19 at 01:13

0 Answers0