Camera Calibration in OpenCV, Graded Against the Truth (fx ±0.12 px)
Mehul Kumawat
0:00 / 0:00
Camera Calibration in OpenCV, Graded Against the Truth (fx ±0.12 px)
29 просмотров · 2 нед. назад
Mehul Kumawat
36 подписчиков
29 просмотров · 2 нед. назад
Two OpenCV calibrations of the same camera both report a reprojection error well under a pixel, 0.137 px and 0.093 px. One has a focal length 58.71 px too long; the other is off by 0.12 px. To show which is which, every checkerboard photo in this episode is rendered synthetically from a camera whose K and lens distortion we chose, so OpenCV's answer can be graded against the truth, number by number. We walk through findChessboardCorners, cornerSubPix and calibrateCamera(Extended), measure how many views you need, and show three gotchas that give a calibration that looks fine and is wrong.
What you'll learn
The calibration set-up: unknown K (fx, fy, cx, cy) + 5 distortion coefficients, a board with known geometry
Why square-on views cannot separate focal length from distance, and why tilting the board pins f down
20 views × 54 corners × 2 = 2 160 measurements for 129 unknowns; Levenberg–Marquardt converging in 8 iterations
Recovered vs true: fx 1150.12 vs 1150.00 (± 0.52), cx 961.90 vs 962.00, k1 −0.2590 vs −0.2600, RMS 0.093 px
How many views: median fx error 1.77 px with 3 views (worst 10.6), 0.35 px with 10, 0.12 px with 20
Gotcha: patternSize counts INNER corners; (10, 7) fails after about 20 s of searching, (9, 6) takes milliseconds
Gotcha: 10 square-on views give RMS 0.137 px and fx +58.71 px; the reported σ (± 56 px) is the alarm
Gotcha: cornerSubPix winSize is a HALF size; (11, 11) reaches the next corner on a far board (4.35 px off)
Chapters
0:00 Intro
0:41 Mental model
2:17 Production code
4:52 Gotchas
6:09 Results
All images are rendered synthetically from a known camera (fx 1150, fy 1147, cx 962, cy 545, k1 −0.26, k2 0.07, p1 0.001, p2 −0.0006). OpenCV 5.0, NumPy 2.
#computervision #opencv #cameracalibration #python #checkerboard #3dvision #lensdistortion #cameramodel