Open EgalYue opened 6 years ago
I am wondering why the condition number is asymmetric, it is better on Y+. Rotate the camera around its Z axis and repeat the test to see if yaw angle has an influence.
I think, the reason for condition number asymmetric is: the image points of symmetrical cam position are different. And i tested for 2 cam postions. cam position: [ 0., 0.40957603, 0.28678823] image points: [[ 512.6557029 127.3442971 638.19502511 1.80497489] [ 129.49722282 129.49722282 422.5091646 422.5091646 ] [ 1. 1. 1. 1. ]] cond num : 6562.11683517
cam position: [ 0. , -0.40957603 , 0.28678823] image points: [[ 638.19502511 1.80497489 512.6557029 127.3442971 ] [ 57.4908354 57.4908354 350.50277718 350.50277718] [ 1. 1. 1. 1. ]] cond num: 4368.18626759
"in X axis only a few cam positions are valid." What do you mean by "valid"?. I think that you have an error, when you move a REAL camera in front of a marker you have way more valid positions around the marker, the field of view in X is lower than in Y but still is not like what you have in the figures.
I also considered this issue once time. I used 4 cam positions(2 cams on Y axis, 2 cams on X axis) to test. I found that for the same height, after using Lookat method we got different R, and t for each cam position. The cam position which on X axis after projecting the object points, the image points are out of the bound of image: https://github.com/EgalYue/Mobile_Marker_Based_Navigation/blob/9b3222ffedd7a6619a34a0c430cd77b61bbe1a9e/python/vision/camera_distribution.py#L395 https://github.com/EgalYue/Mobile_Marker_Based_Navigation/blob/9b3222ffedd7a6619a34a0c430cd77b61bbe1a9e/python/vision/camera_distribution.py#L396 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 .camera on X axis, This cam position is not valid: cam position : [ 2.12132025 0. 2.12132025] cam R: [[-0.70710678 0. -0.70710678 0.] [ 0. 1. 0. 0. ] [ 0.70710678 0. -0.70710678 0.] [ 0. 0. 0. 1. ]] image points are out of bound: [[ -2.31074160e+04 2.21474160e+04 -2.31074160e+04 2.21474160e+04] [ 1.37137085e+03 -8.91370850e+02 -8.91370850e+02 1.37137085e+03] [ 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00]]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2.camera on X axis, This cam position is not valid: cam position : [ -2.12132025e+00 2.59786805e-16 2.12132025e+00] cam R: [[ -7.07106781e-01 6.12323399e-17 7.07106781e-01 0.00000000e+00] [ 0.00000000e+00 1.00000000e+00 -8.65956055e-17 0.00000000e+00] [ -7.07106781e-01 -6.12323399e-17 -7.07106781e-01 0.00000000e+00] [ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]] image points are out of bound: [[ -2.15074160e+04 2.37474160e+04 -2.15074160e+04 2.37474160e+04] [ -8.91370850e+02 1.37137085e+03 1.37137085e+03 -8.91370850e+02] [ 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00]]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3.camera on Y: cam position : [1.29893402e-16 2.12132025e+00 2.12132025e+00] cam R: [[ -1.00000000e+00 -4.32978028e-17 -4.32978028e-17 0.00000000e+00] [ 0.00000000e+00 7.07106781e-01 -7.07106781e-01 0.00000000e+00] [ 6.12323399e-17 -7.07106781e-01 -7.07106781e-01 0.00000000e+00] [ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]] [ 1.29893402e-16 2.12132025e+00 2.12132025e+00 1.00000000e+00]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4.camera on Y: cam position : [ -3.89680234e-16 -2.12132025e+00 2.12132025e+00] cam R: [[ -1.00000000e+00 -1.29893417e-16 1.29893417e-16 0.00000000e+00] [ 0.00000000e+00 7.07106781e-01 7.07106781e-01 0.00000000e+00] [ -1.83697032e-16 7.07106781e-01 -7.07106781e-01 0.00000000e+00] [ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Display R_Error and tError of cam distribution on YZ plane for cv2.SOLVEPNP_DLS, cv2.SOLVEPNP_EPNP,cv2.SOLVEPNP_ITERATIVE_ Using 2 ways to display(1. using colormap; 2. using 3D): ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cv2.SOLVEPNP_DLS: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cv2.SOLVEPNP_EPNP: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cv2.SOLVEPNP_ITERATIVE
Something is wrong Yue. It is not possible that you have such a big restriction in the field of view, that simply doesn't happen with a real camera. Please check, again, if it is necessary you would have to compare against real results from a real camera to compare.
I have an idea, you can test what is wrong by creating a camera that has an image with the same width and height (a square camera), then you should have valid camera poses completely symmetric, if you don't, then there is a problem somewhere.
Finally finally finally!!! I found the error, i make a really big mistake: The R rotation matrix in camera.py is from camera coordinate to world coordinate, not from world to camera coordinate! So your ""Lookat" method is totally right! inv(R) = R.T
So all the results above are wrong! tomorrow i will run the simulations again,it will take some time
Now I find out, why the condition number is asymmetric:
According to the paper, c(A) = s1 / s8 and A is composed of 4 object points and 4 image points, we know that the object points always be origin(constant), so the only affected factor is 4 image points. So we can see what is happened by image points: Different cam position(Symmetrical cam position) on YZ plane has different R. And we can get different image points according to R.
The Symmetrical cam positions, which are closer to Z-axis (theta = 90) and Y-axis (theta = 0), get almost similar image points -> so similar condition number (smaller difference). At somewhere theta between 0 - 90, we get the biggest difference of condition number on Symmetrical cam positions.
theta = 0, 180, image points exactly same
theta = close to 90, image points exactly very similar
theta = between 0 - 90, image points big difference
The new simulation results: cam distribution: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ DLS: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ EPNP: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ITERATIVE:
normalize points: condition number cam distribution
I just find a problem, when i focused on the both following images: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ without normalization: it seems not exactly right when the Angle changes, ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ with normalization: Do not work for the Height
And now im thinking to use the Taubin estimator method instead of normalization. Im not sure about this, maybe need to discuss this problem with you.
normalised Homography without scale:
the scale should be set as 1 : scale = 1 BUT in this case the condition number distribution seems not right! After reading Multiple View Geometry in Computer Vision Second Edition Page 107,108,there is a explain for Why is normalization essential? I think if we do not use scale(just set scale = 1), we can not get the purpose of the normalization.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ And in a alternative way we already know that , when the cam height increases, the cond num can get bigger! So i set the *_scale = radiusnp.sqrt(2) / meandist_**, which means for different height(distance from camera to marker) we set different scale. But im not sure whether we can do like this. And following is the distribution
Hi Yue, are you applying the same normalization function both to Image Coordinates and Object Coordinates?. Try to apply the modified normalization (with scale=1) only to image coordinates and use the regular normalization for object coordinates.
I make simulation for both cases again, for both case i apply image points with modified normalization (with scale=1) :
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cam distribution on YZ plane using matplotlib colormap: