cvg / Hierarchical-Localization

Visual localization made easy with hloc
Apache License 2.0
3.21k stars 597 forks source link

3D mapping vs localization accuracy of tvec #345

Open messileonardo opened 10 months ago

messileonardo commented 10 months ago

I would like to ask whoever can help me clarification about 3D mapping and localization accuracy of tvec. I did this experiment:

  1. I choose 20 positions in a grid in which each point is 1 meter distant each other. I assumed the first position in the bottom left side is (0,0,0). From this assumption I have the real position of each photo.
  2. For each position, I shot 2 photos using a camera stand.
  3. I used 1 photo for each position for the 3d mapping (green frustum below) and then I localized the remaining ones (red frustum below). image
  4. 3d mapping ("sfm") and localization ("loc") parameters image
  5. I scaled the sfm model using the model_aligner function in colmap giving the real position of 3 photos.
  6. I computed the average errors (measured as linear distance and using ransac.max_error = 12) between

and finally using as ransac.max_error = 50 and I computed the average errors (measured as linear distance) between

Many thanks in advance to everyone can help me!

messileonardo commented 10 months ago

With reference to the first question " Why 3d mapping is more accurate than localization? I am aware that configuration parameters are different between 3d mapping and localization (I did that to make localization faster), but this can be the real explanation? " I did another test with the same configuration between 3d mapping and localization image and I copmuted the average errors (measured as linear distance and using ransac.max_error = 12) between

Error are very similar to the case with different configuration. So, why 3d mapping is more accurate than localization (about 3 cm error vs 6.5 cm error respectively)? Many thanks

messileonardo commented 10 months ago

I will try to sum up my questions.

  1. What could be possible causes of different accuracy between mapping (about 3 cm error) and localization (about 6.5 cm error)?
  2. Since I noticed that lower ransac.max_error threshold do not provide better localization results, what could be the logic to follow to properly set this value?

Many thanks to everyone can help me.

sarlinpe commented 10 months ago

The mapping of each image starts the estimate the absolute pose, which is identical to the localization process, and it followed by a retriangulation of the 3D points and by a full bundle adjustment, which refines both poses and camera intrinsic parameters. This explains why mapping poses and more accurate than poses estimated by the localization process.

messileonardo commented 10 months ago

Many thanks @sarlinpe ! What about ransac.max_error threshold during localization? Can you suggest a logic to set it or a minimum number of inliers to get for a good localization or what else? Thanks again!

sarlinpe commented 9 months ago

It depends on your data. The default value is generally sufficient, and it can be decreased if necessary.