Skip to content

dhruvilad34/camera-calibration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camera Calibration

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.

Setup

Just install the dependencies:

pip3 install -r requirements.txt

You'll need numpy and opencv-python (though only the OpenCV script actually uses opencv).

Input Files

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.

Running the Scripts

OpenCV method:

python3 opencv_calibrate.py

Uses 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.py

Pure 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.

Sample Output (OpenCV vs SVD Calibration)

Screenshot 2025-12-07 at 10 12 01 PM

About

Python-based project for camera calibration and stereo vision using OpenCV. Includes techniques for estimating intrinsic and extrinsic parameters, disparity maps, and 3D reconstruction.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages