How to solve the distortion coefficients in camera calibration

I download the opencv source code,but i dou’t see the source code about how to solve the distortion coefficients.
And more important, about zhang’s method ,he only think of radial distortion,then I can learn how to solve radial distortion,but i don’t konw the theory about how to solve the tangential distortion,can you give me some suggestion,thank you all at first.

You should look into calibrateCamera() and aruco::calibrateCameraCharuco. The charuco method uses a different calibration pattern but otherwise uses the same underlying calibration process (calibrateCamera) which has many options and is capable of computing tangential distortion. Take note of the distortion coefficients ordering - the 3rd and 4th coefficients are the tangential distortion.

I suggest the charuco calibration because you don’t have to see the entire calibration pattern in a given image which makes it easier to capture points that are close to the corners of the image (which give you a better distortion model).

Thanks for explaining,however I want to know more details about how to calculate these distortion coefficients in source code, I can’t find it, please forgive me for asking such a silly question.

You can call the calibrateCamera() function if you want to get the values.

If you are asking about how it works / the theory behind it / etc. you might want to look at the source code (calib3d/src/calibration.cpp), read books, articles etc. related to camera calibration.

*Thank you very much. You really helped me a lot!