cvg / Hierarchical-Localization

Visual localization made easy with hloc
Apache License 2.0
3.19k stars 594 forks source link

How do I prepare the custom dataset? #7

Closed Zumbalamambo closed 4 years ago

Zumbalamambo commented 4 years ago

I have set of images, 6dof positions of images. How do i structure is in such a way that the hfnet requires it to be.

sarlinpe commented 4 years ago

If you already have 6DoF poses of the images, you simply need to triangulate a new 3D SfM model. This requires:

  1. Building a COLMAP reference model. See how to create cameras and images. You can provide an empty Points3D dictionary (no pointcloud).
  2. Establishing a list of matching images:
    1. With exhaustive matching: if you have few (<100) images, see here.
    2. Using covisibility of an existing 3D model: if you also have 3D points, see hloc/pairs_from_covisibility.py.
    3. Using image retrieval, like NetVLAD: see instructions here.
  3. Running the triangulation, similarly as in the Aachen pipeline.
Zumbalamambo commented 4 years ago

@Skydes I do have the point cloud as well. Do I still need to use COLMAP? These are the components that I have.

  1. Point cloud of the entire rooms.
  2. Images with 6dof pose information. These 6DOF poses can pinpoint where exactly the camera is in the point cloud.
  3. Camera Intrinsic Parameters.
sarlinpe commented 4 years ago

Yes, we use COLMAP for the triangulation of the SuperPoint+SuperGlue SfM model, and the COLMAP data format for I/O. As described above, first format your data into binary a COLMAP model. Then run all the steps of the Aachen pipeline.

Zumbalamambo commented 4 years ago

I'm still stuck with creating a colab model for hierarchical localization :P I have been trying to follow your guidelines. Is there any documentation or code sample that creates colmap model based on the image data that has got the 6dof pose already? May be with colmap gui?

Zumbalamambo commented 4 years ago

I also noticed this function this https://github.com/cvg/Hierarchical-Localization/blob/b005824c90eebaf3392d3ac464964edf5c126344/hloc/colmap_from_nvm.py#L13

In my case, how shall I structure it accordingly? what must be the camera_id,image_id, and name? :)

sarlinpe commented 4 years ago

This function is used if a COLMAP database is already available. In your case: iterate through your images, and create a new Camera and Image for each. Pick a unique integer id for each, e.g. camera_id = image_id = index_of_the_image, and use the filename of the image as the name. Also iterate though the pointcloud, create a Point3D for each point, also with an id, and fill in the covisibility information that links images and points.

Zumbalamambo commented 4 years ago

@Skydes thank you!... I'm doing it currently. May I know what is params ?

I used mobile camera to capture the images so should I choose SIMPLE_PINHOLE?

sarlinpe commented 4 years ago

How did you obtain the camera intrinsics? The camera models are described here, pick one that corresponds to your calibration. Use SIMPLE_PINHOLE if you have a single focal length, and no distortion.

Shubodh commented 1 year ago

@Zumbalamambo Have you done it? What he mentioned as quoted above?

@Skydes If I have a dataset like InLoc with poses and 3D points for every reference image, is there an example which builds the COLMAP database (which involves creation of unique IDs for Points3D, Camera, Image etc)? I am aware of pipeline_InLoc.ipynb but I am not looking to localize query image. Instead: I am basically trying to implement "covisibility clustering for InLoc". From what I understand, I can do it in following two ways:

  1. if I have my data in COLMAP database format, it is very easy to implement covisibility clustering by inputting that COLMAP reconstruction object to the function do_covisibility_clustering(). Here I don't want to do any reconstruction though, since I already have 3D point sets and their corresponding poses.
  2. Otherwise, I can avoid COLMAP database but will have to heavily rewrite do_covisibility_clustering() which involves defining unique IDs for Points3D, Camera, Image etc. If I have to do that anyway, I might as well create COLMAP database and just use do what I mentioned in the first point?

Let me know if I am on right track and please give further directions.

Shubodh commented 1 year ago

Created new issue for this, we can keep this issue closed and continue there instead.