Two different approaches to camera calibration - one using OpenCV's built-in functions and another using SVD (Direct Linear Transform). Both scripts take 3D-2D point correspondences and compute the camera projection matrix.
Just install the dependencies:
pip3 install -r requirements.txtYou'll need numpy and opencv-python (though only the OpenCV script actually uses opencv).
The scripts expect two files:
3D.txt- 3D world coordinates (X, Y, Z per line)2D.txt- corresponding 2D image coordinates (u, v per line)
First line of each file should be the point count, then the coordinates follow.
OpenCV method:
python3 opencv_calibrate.pyUses OpenCV's calibrateCamera which handles distortion and gives you rotation/translation vectors. Starts with a reasonable initial guess for the intrinsic matrix (focal length ~500, principal point at image center).
SVD method:
python3 svd_calibrate.pyPure numpy implementation using DLT. Builds the system of equations and solves via SVD. Simpler approach but doesn't handle distortion - just gives you the projection matrix directly.
Both print out the 3x4 projection matrix and the average reprojection error so you can compare results.