SergioRAgostinho / zhou-accv-2018

A Python 3 implementation of "A Stable Algebraic Camera Pose Estimation for Minimal Configurations of 2D/3D Point and Line Correspondences." by Zhou et al. ACCV 2018
Apache License 2.0
31 stars 12 forks source link

Problem running e3q3 #2

Closed dkoppel11 closed 4 years ago

dkoppel11 commented 4 years ago

The e3q3 routine fails for a simple case that should succeed:

Here are the contents of my python test file (test_e3q3.py):

import numpy as np
from zhou_accv_2018 import e3q3

A = np.array([[ 1,  1,  1,  0,  0,  0,  0,  0,  0, -4],
       [ 1,  1,  1,  0,  0,  0, -4,  0,  0,  3],
       [ 1,  1,  1,  0,  0,  0,  -3.5,  0,  0,  2.125]])

a_gt = 1.75
b_gt = np.sqrt(15)/4
c_gt = 0

v_gt = np.reshape(np.array([a_gt**2, b_gt**2, c_gt**2, a_gt*b_gt, a_gt*c_gt, b_gt*c_gt, a_gt, b_gt, c_gt, 1]), (-1, 1))

print(np.matmul(A, v_gt)) # should be 3 zero's

a, b, c = e3q3(A, True)

Here is the output of running it:

$ python test_e3q3.py
[[0.]
 [0.]
 [0.]]
Traceback (most recent call last):
  File "test_e3q3.py", line 16, in <module>
    a, b, c = e3q3(A, True)
  File "/home/dkoppel/Downloads/zhou-accv-2018-master/dan2/lib/python3.6/site-packages/zhou_accv_2018-1.0.0-py3.6-linux-x86_64.egg/zhou_accv_2018/e3q3.py", line 60, in e3q3
    A_r = (A.T)[perms[min_idx]]
TypeError: list indices must be integers or slices, not NoneType

Maintainer edit: code formatting

SergioRAgostinho commented 4 years ago

@dkoppel11 the issue is that your input violates one of the core assumptions of the method. I invite you to read section 3.1 of the original paper. The input your supplied is exactly one of those degenerate configurations mentioned in that section.

This means that these solvers do not work for ‘degenerate’ inputs, e.g., when one or more of the input quadrics are in fact planes or curves or when certain coefficients vanish

So this is not a bug per se, but I will make sure the implementation throws an exception warning about an ill-conditioned input.

SergioRAgostinho commented 4 years ago

Addressed in c4760a371fe9445e51556c50bf7c6422dcaf2ffe

dkoppel11 commented 4 years ago

Hi Sergio,

I'm a bit confused. The set of coefficients I used represent 3 spheres of different radii intersecting. The way I obtain these coefficients is the following:

consider 2 circles that intersect on the x-y plane first circle is centered at the origin and has radius = 2 second circle is centered at (2, 0) and has radius = 1

It's easy to find 2 points of intersection: (1.75, sqrt(15)/4) and (1.75, -sqrt(15)/4)

I then add a z^2 term to both circles to make them spheres. I then add a 3rd circle in yz plane for x = 1.75 and passing through the 2 points above where the points are on opposite sides of the circle. I then turn the circle into a sphere by adding x^2 term.

This gives me 3 spheres that intersection in a non-degenerate way.

What makes this a "bad" intersection of sphere?

Thanks, ~ Dan

On Tue, Jun 30, 2020 at 7:14 AM Sérgio Agostinho notifications@github.com wrote:

Addressed in c4760a3 https://github.com/SergioRAgostinho/zhou-accv-2018/commit/c4760a371fe9445e51556c50bf7c6422dcaf2ffe

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SergioRAgostinho/zhou-accv-2018/issues/2#issuecomment-651818823, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGPQ5UYSIUWQRNEQ2G5VGDRZHXLLANCNFSM4OL3GMOA .

SergioRAgostinho commented 4 years ago

I understand you're supplying a human interpretable case, but E3Q3 does not handle all possible quadrics.

What makes this a "bad" intersection of sphere?

Check equation (4) of the paper. See that matrix A, it needs to be invertible. WIth the coefficients you're supplying, it is not. That is the assumption that your input is breaching.

dkoppel11 commented 4 years ago

Thanks Sergio. I will take a look at the paper, section 3.1 and eq 4. Thanks very much for pointing this out. Best, ~ Dan

On Wed, Jul 1, 2020 at 12:39 AM Sérgio Agostinho notifications@github.com wrote:

I understand you're supplying a human interpretable case, but E3Q3 does not handle all possible quadrics.

What makes this a "bad" intersection of sphere?

Check equation (4) of the paper. See that matrix A, it needs to be invertible. WIth the coefficients you're supplying, it is not. That is the assumption that your input is breaching.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SergioRAgostinho/zhou-accv-2018/issues/2#issuecomment-652249110, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGPQ5TXZCNHDFVCSCKI66TRZLRZLANCNFSM4OL3GMOA .