0

OpenCV provides methods to calibrate a camera. I want to know if it also has a way to simply generate a view projection matrix if and when the parameters are known.

i.e I know the camera position, rotation, up, FOV... and whatever else is needed, then call MagicOpenCVCamera(parameters) and obtain a 4x4 transformation matrix.

I have searched this up but I can only find information about calibrating the camera, not about creating one if you already know the parameters.

Makogan
  • 8,208
  • 7
  • 44
  • 112
  • why do you want to do this? my guess would be that no real, physical, camera is perfect nor can you measure those those things perfectly. there will always be some error, and "calibrating" allows the parameters to be fit to the image, which is presumably the data you care about – Sam Mason Sep 06 '19 at 18:24
  • Because I already have the camera data (estimated beforehand by a different process that has nothing to do with opencv) and now need to use OpenCV to do some calculation, but I need a projection matrix. – Makogan Sep 06 '19 at 18:44
  • which "projection matrix" are you talking about? are you just looking for tutorials like https://www.scratchapixel.com/lessons/3d-basic-rendering/perspective-and-orthographic-projection-matrix/opengl-perspective-projection-matrix – Sam Mason Sep 07 '19 at 09:33

1 Answers1

1

The projection matrix is simply a 3x4 matrix whose [0:3,0:3] left square is occupied by the product K.dot(R) of the camera intrinsic calibration matrix K and its camera-from-world rotation matrix R, and the last column is K.dot(t), where t is the camera-from-world translation. To clarify, R is the matrix that brings into camera coordinates a vector decomposed in world coordinates, and t is the vector whose tail is at the camera center, and whose tip is at the world origin.

The OpenCV calibration routines produce the camera orientations as rotation vectors, not matrices, but you can use cv.Rodrigues to convert them.

Francesco Callari
  • 11,300
  • 2
  • 25
  • 40