Skip to content

Commit 3579ba0

Browse files
committed
moved notes out of readme
1 parent f1fa751 commit 3579ba0

File tree

2 files changed

+62
-71
lines changed

2 files changed

+62
-71
lines changed

README.md

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,87 +2,20 @@
22

33
[![Build Status](https://app.travis-ci.com/pvphan/camera-calibration.svg?branch=main)](https://app.travis-ci.com/pvphan/camera-calibration)
44

5-
A simple library for calibrating camera intrinsics from a json file of sensor (2D) and model point (3D) correspondences.
6-
Written primarily as an exercise with few external dependencies (numpy, sympy, imageio) for a deeper understanding.
5+
A simple library for calibrating camera intrinsics from sensor (2D) and model point (3D) correspondences.
6+
Written with few external dependencies (numpy, sympy, imageio) for a deeper understanding.
77
Also generates synthetic datasets for testing and rudimentary visualization.
88

99
Prerequisites: `make`, `docker`
1010

1111

1212
## TODO:
1313

14-
- [x] Generate dataset to test on (dataset.py)
15-
- [x] From 2D / 3D feature correspondences, estimate the homography (DLT-like estimation)
16-
- [x] Compute close form solution for K based on homographies (ignore lens distorion)
17-
- [x] Compute extrinsics R, t for each view
18-
- [x] Compute distortion using linear least squares
19-
- [x] Use estimated parameters as initial guess and refine using non-linear optimization over all views
20-
- [x] Write main method interface for calibrating from json files
21-
- [x] Support full radial-tangential distortion model
22-
- [x] Write nonlinear optimization by hand instead of using SciPy
23-
- [ ] Try vectorizing the Jacobian computation (takes ~14 sec per iteration of LM currently)
24-
- [ ] Button up as python package
14+
- [ ] Vectorize the Jacobian computation (takes ~14 sec per iteration of Levenberg-Marquardt currently)
15+
- [ ] Button up as python package, add instructions to README
2516
- [ ] Support fisheye distortion model
2617

2718

28-
## Notes:
29-
- Need 6 points to find transform matrix P in the equation x = P * X. 11 unknowns, each point gives 2 variables, so 11 / 2 = 5.5 ~= 6
30-
- P = [H | h]
31-
- X0 = -H^-1 * h
32-
- To decompose H = KR into the intrinsic and rotation matrices, use QR-decomposition.
33-
- In QR-decomposition, Q is a rotation matrix, R is a triangular matrix.
34-
- H^-1 = (K * R)^-1 = R^-1 * K^-1 = R^T * K^-1
35-
- Q = R^T
36-
- R = K^-1
37-
- Need to normalize K, e.g. K = 1/K33 * K
38-
- Need to do a coordinate tranform by a rotation of 180 deg
39-
- K = K * R(z, 180)
40-
- R = R(z, 180) * R
41-
42-
- DLT in a nutshell
43-
1. Build M for the linear system: M is (2 * i, 12) and p is (12, 1). M * p = 0.
44-
For every point we measure, we add 2 rows to the matrix M (minimum of 6 points which is 12 rows).
45-
46-
2. Solve by SVD M = U S V^T, solution is the last column of V, which are the values of p which gives us P.
47-
3. Solve for K, R, X0. Let P = [H | h]
48-
- X0 = -H^-1 * h
49-
- QR(H^-1) = R^T * K^-1
50-
- R = R(z, 180) * R
51-
- K = (1/K33) * K * R(z, 180)
52-
53-
- What were the innovations of Zhang calibration over the prior state of the art?
54-
55-
- Previous calibration techniques required more expensive or procedures: specially made 3D calibration targets, or targets that are moved in a precise way.
56-
- Zhang's method requires only a 2D planar target (cheap to print) and requires no special movements
57-
58-
- Under what conditions will this calibration method fail?
59-
60-
- If the calibration target undergoes pure, unknown translation, Zhang's method will not work.
61-
- This is because additional views on the same model plane do not add additional constraints.
62-
- But if the translation of the target is precisely known, then calibration is possible if we impose those constraints.
63-
64-
- At a high level, what are the steps to the Zhang calibration algorithm?
65-
66-
- Collect feature points (2D / 3D point associations) from several images (assumed to be done)
67-
- Estimate the intrinsic and extrinsic parameters using the closed form solution
68-
- Estimate the radial distortion parameters
69-
- Refine all parameters by minimizing
70-
71-
- What is SVD, DLT, and QR, and how do they relate to Zhang calibration?
72-
73-
- In the DLT case, QR-decomposition is used to decouple the intrinsics (K) and the rotation matrix (R) from the full projection matrix P.
74-
- But in Zhang's method, we cannot use QR-decomposition because the product contains the intrinsic matrix and a matrix which is not orthogonal (r1, r2, t)
75-
- x = P * X, P = [H | h], H = K * R
76-
- QR-decomposition separates H into its two products: an orthogonal matrix (the rotation matrix, R) and an upper-diagonal matrix (the intrinsic matrix, K)
77-
- Instead, we will drop the z terms (every 3rd col) of the linear system and solve for the 3x3 homography H
78-
79-
- Still need to estimate K from H: H = K * [r1 r2 t]. So we need a custom solution to exploit properties we know about K, r1, and r2
80-
1. Exploit constraints on K, r1, r2
81-
2. Define a matrix B = K^-T * K^-1
82-
3. Compute B by solving another homogeneous linear system
83-
4. Decompose matrix B to get K
84-
85-
8619
## References:
8720
- (paper) [Wilhelm Burger: Zhang's Camera Calibration Algorithm: In-Depth Tutorial and Implementation](https://www.researchgate.net/publication/303233579_Zhang's_Camera_Calibration_Algorithm_In-Depth_Tutorial_and_Implementation).
8821
- (paper) [Zhengyou Zhang: A Flexible New Technique for Camera Calibration](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr98-71.pdf)

notes.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Notes:
2+
3+
- Need 6 points to find transform matrix P in the equation x = P * X. 11 unknowns, each point gives 2 variables, so 11 / 2 = 5.5 ~= 6
4+
- P = [H | h]
5+
- X0 = -H^-1 * h
6+
- To decompose H = KR into the intrinsic and rotation matrices, use QR-decomposition.
7+
- In QR-decomposition, Q is a rotation matrix, R is a triangular matrix.
8+
- H^-1 = (K * R)^-1 = R^-1 * K^-1 = R^T * K^-1
9+
- Q = R^T
10+
- R = K^-1
11+
- Need to normalize K, e.g. K = 1/K33 * K
12+
- Need to do a coordinate tranform by a rotation of 180 deg
13+
- K = K * R(z, 180)
14+
- R = R(z, 180) * R
15+
16+
- DLT in a nutshell
17+
1. Build M for the linear system: M is (2 * i, 12) and p is (12, 1). M * p = 0.
18+
For every point we measure, we add 2 rows to the matrix M (minimum of 6 points which is 12 rows).
19+
20+
2. Solve by SVD M = U S V^T, solution is the last column of V, which are the values of p which gives us P.
21+
3. Solve for K, R, X0. Let P = [H | h]
22+
- X0 = -H^-1 * h
23+
- QR(H^-1) = R^T * K^-1
24+
- R = R(z, 180) * R
25+
- K = (1/K33) * K * R(z, 180)
26+
27+
- What were the innovations of Zhang calibration over the prior state of the art?
28+
29+
- Previous calibration techniques required more expensive or procedures: specially made 3D calibration targets, or targets that are moved in a precise way.
30+
- Zhang's method requires only a 2D planar target (cheap to print) and requires no special movements
31+
32+
- Under what conditions will this calibration method fail?
33+
34+
- If the calibration target undergoes pure, unknown translation, Zhang's method will not work.
35+
- This is because additional views on the same model plane do not add additional constraints.
36+
- But if the translation of the target is precisely known, then calibration is possible if we impose those constraints.
37+
38+
- At a high level, what are the steps to the Zhang calibration algorithm?
39+
40+
- Collect feature points (2D / 3D point associations) from several images (assumed to be done)
41+
- Estimate the intrinsic and extrinsic parameters using the closed form solution
42+
- Estimate the radial distortion parameters
43+
- Refine all parameters by minimizing
44+
45+
- What is SVD, DLT, and QR, and how do they relate to Zhang calibration?
46+
47+
- In the DLT case, QR-decomposition is used to decouple the intrinsics (K) and the rotation matrix (R) from the full projection matrix P.
48+
- But in Zhang's method, we cannot use QR-decomposition because the product contains the intrinsic matrix and a matrix which is not orthogonal (r1, r2, t)
49+
- x = P * X, P = [H | h], H = K * R
50+
- QR-decomposition separates H into its two products: an orthogonal matrix (the rotation matrix, R) and an upper-diagonal matrix (the intrinsic matrix, K)
51+
- Instead, we will drop the z terms (every 3rd col) of the linear system and solve for the 3x3 homography H
52+
53+
- Still need to estimate K from H: H = K * [r1 r2 t]. So we need a custom solution to exploit properties we know about K, r1, and r2
54+
1. Exploit constraints on K, r1, r2
55+
2. Define a matrix B = K^-T * K^-1
56+
3. Compute B by solving another homogeneous linear system
57+
4. Decompose matrix B to get K
58+

0 commit comments

Comments
 (0)