I have OpenCV code for calculating camera matrix and fixing distortion in image. Here is the part of the code …