Image-Rectification
Image-Rectification copied to clipboard
3-line RANSAC function seem to be wrong
h = np.dot(vp1, [1 / f**2, 1 / f**2, 1])
vp2 = np.cross(h, l3)
The original code will cause 'AxisError: axisa: axis -1 is out of bounds for array of dimension 0' error, because h is a number and l3 is a vector.
I guess what you want to implement is:
h = [vp1[0]*(1 / f**2), vp1[1]*(1 / f**2), vp1[2]]
vp2 = np.cross(h, l3)
It works well on the test image.
Hi, somehow I don't understand these two lines, could you possibly explain what is being calculated here (to be exact, i HAVE read the paper, however am none the wiser after doing so) ? Also in the original code the focal_length is set to None, however you say that the code is working on the presented image, how did you figure out the focal_length?
Hi, somehow I don't understand these two lines, could you possibly explain what is being calculated here (to be exact, i HAVE read the paper, however am none the wiser after doing so) ? Also in the original code the focal_length is set to None, however you say that the code is working on the presented image, how did you figure out the focal_length?
Focal_length defaults to None, but you can pass arguments to the function. To be honest, I don't really understand how the code works, but it works.
Hi, I can figure out a little, but not fully understand. let me give some comments. Please tell me if I am wrong.
- We first assume that
l1
andl2
are the images of parallel linesL1
andL2
respectively in the 3D world. - The vanishing point of parallel line images
l1
andl2
isvp1
-
vp1
can be seen as the image of some line in the 3D world, sayL
, this 3D line joins the camera centerC
,andvp1
in the image plane, (see Vanishing Points and Their Applications if if you do not understand this) - Now we want to find the valishing line
h
of the 3D planeP
which is perpendicular toL
. Note the camera centerC
is also on the 3D planeP
. - So how can we find the valishing line
h
? The answer is,see equation 4 in
Abbas, Syed Ammar, and Andrew Zisserman. “A Geometric Approach to Obtain a Bird’s Eye View From an Image.” In 2019 IEEE/CVF International Conference on Computer Vision Workshop (ICCVW), 4095–4104. Seoul, Korea (South): IEEE, 2019. https://doi.org/10.1109/ICCVW.2019.00504.
, see here for the expansion (in the expansion,
cx
, cy
denotes the focal point)