# I have footage but not the camera: how am I going to correct the lens distortion?

I should have thought this would be a staple of any image library, but I've been having a rough time figuring out how to do it with OpenCV. (I am a new user, trying to figure things out for the first time.)

I have footage from 1972 with noticeable radial distortion. There are several rectangles in the picture, and I think there must be some method to use these to estimate a transformation to correct the radial distortion in the image. What strategies could I use to correct the radial distortion when all I can do is make educated guesses about the rectangles in the picture?

I've read that Zhang's method to correct radial distortion is capable of doing something like this, and is purportedly implemented in OpenCV somewhere, but I can't seem to find it in the documentation. Thanks for any advice.

This is called camera autocalibration or self calibration, but I have not been able to find a working implementation in Matlab or OpenCV. Either links are broken or just papers are available, but no code :(

A naive solution would be to mark straight lines and iteratively adjust camera parameters until thee lines and angles become straight enough (if you are sure that there are rectangles). The problem is there adre many parameters to optimize. Perhaps it is possible, however, to assume that the optical center of the lens is in the image center, that there is no skew, that focal length is identical for x and y directions and that there are no tangential distortions... this would result in 3 or 4 parameters to find: focal length and 2 or 3 radial distortion coefficients. It could work