A collection of pitfalls and tricky parts of SDC projects
I created this document to collect all tricky parts which I found while I was doing projects and which I discovered while I was mentoring other students.
Feel free to add more if you have any by submitting a pull request.
In the course video Calibrating Your Camera and the example code in project repo under examples/, we see the following code
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
objp = np.zeros((6*9,3), np.float32)
objp[:,:2] = np.mgrid[0:9,0:6].T.reshape(-1,2)
mgrid returns a 3-d ndarray, which contains 2 matrices. These 2 matrices are just counting numbers from different dimention. One horizontally(dimension 0), another vertically(dimension 1).
>>> mgrid[0:3,0:4]
array([[[0, 0, 0, 0],
[1, 1, 1, 1],
[2, 2, 2, 2]],
[[0, 1, 2, 3],
[0, 1, 2, 3],
[0, 1, 2, 3]]])
.T returns the transpose matrix of a ndarray. Please refer to:
- https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.T.html
- https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.transpose.html
.reshape reshapes the ndarray. (-1,2) just means "compute the length of this dimension by number of elements / 2"