pythonopencvcameraslamcamera-matrix

Determining the approximate camera matrix


I would like to determine the camera matrix of a feed. The image is of width shape=(1440,2960) where 1440 is the height and 2960 is the width.

I would like to find the camera matrix for the same. I used the following calculation to find cx,cy

cx = shape[1]/2
cy = shape[0]/2

How do I find an approximate fx and fy? I tried to use shape[1] as my focal length but it doesn't seem to work for some reason :(


Solution

  • As you mentioned, shape[1] is the width of your image. So you obviously can't use it as the focal length. There is no way to determine the focal length based on the image size alone. You either know the intrinsic parameters of your camera or you need to calibrate it. For more information, see the following docs: https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html https://docs.opencv.org/3.4/dc/dbb/tutorial_py_calibration.html