Image-Rectification icon indicating copy to clipboard operation
Image-Rectification copied to clipboard

3-line RANSAC function seem to be wrong

Open PoetCoderJun opened this issue 3 years ago • 3 comments

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.

PoetCoderJun avatar Jan 19 '21 12:01 PoetCoderJun

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?

boisbb avatar Mar 14 '21 13:03 boisbb

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.

PoetCoderJun avatar Mar 22 '21 12:03 PoetCoderJun

Hi, I can figure out a little, but not fully understand. let me give some comments. Please tell me if I am wrong.

  1. We first assume that l1 and l2 are the images of parallel lines L1 and L2 respectively in the 3D world.
  2. The vanishing point of parallel line images l1 and l2 is vp1
  3. vp1 can be seen as the image of some line in the 3D world, say L, this 3D line joins the camera center C,and vp1 in the image plane, (see Vanishing Points and Their Applications if if you do not understand this)
  4. Now we want to find the valishing line h of the 3D plane P which is perpendicular to L. Note the camera center C is also on the 3D plane P.
  5. 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)

marquistj13 avatar Jul 27 '21 01:07 marquistj13