# What does the getOptimalNewCameraMatrix function does?

For example, in this tutorial, I have some problems in understanding the cv2.getOptimalNewCameraMatrix. Already read the documentation and made some search, but I still can't understand it. I don't get the meaning of the return of this function:

Returns the new camera matrix based on the free scaling parameter

What does "free scaling parameter" means?

I hope someone can give explanation and maybe some examples on this. Thanks.

edit retag close merge delete

Sort by » oldest newest most voted

Consider the image above. It has been undistorted. Lines that are straight in 3D space are now straight in the 2D projection (the 2D image). Radial distortion has been removed. But what's up with the "four pointed star" shape? This is because in order to correct for radial distortion, pixels that are further away from the center of distortion must get pushed more than pixels closer to the center of distortion. See the picture below:

The red dots represent pixel locations before undistorting: they follow a regular grid. But the radial distortion model says that as one moves away from center of distortion, the distortion gets worse. It is called a radial distortion model because this is a function of the size of the radius of a circle centered around the center of distortion. The heads of the blue vectors represent where the red pixels will get undistorted to. Since the original image is a rectangle, the points toward the corners have the highest radius, and they must get pushed out more. But if you want to see every pixel from the original image, this means you will have the black "hills" on the sides of the undistorted image. If you don't want to see these black hills, set alpha to 0. If you do want to see these black hills, set alpha to 1. If you want to see the black hills, but you want them to be smaller, set alpha to 0.5. You get the picture.

more

Parallel lines in 3D space do not have to be parallel in the 2D projection space. Instead,

Straight Lines Have to Be Straight

see this paper.

( 2016-12-24 12:52:37 -0500 )edit

If i understand it correctly it refines your camera calibration parameters based on the input of alpha (0-1). I don't know if you had a look at this.

more

Official site

GitHub

Wiki

Documentation