colmap multi-camera reconstruction multi-scene and database data rapid modification method

1 colmap process

1.1 New project

  First open colmap, and then create a new project, in which the database directory and name are selected by yourself, be careful not to put it in the image directory. Then images selects the image directory (for example, here is guangxi/section1), this directory should contain different folders, and each folder stores images taken by the same camera. Note that there should be no other files in the image directory except the image to be rebuilt. For example, I have five cameras here, and each camera takes 5527 images. The following figure shows the file structure in the guangxi/section1 directory: after selecting it,
insert image description here
  
  click save, as shown in the figure below:
insert image description here
  

1.2 Feature Extraction

  Click Processing- Feature extractionto open the following interface:
insert image description here
  
  The main modified contents include:

  • Camera model: Camera model, choose according to actual needs, I choose OPENCV model here, it includes four distortion parameters k1/k2/p1/p2.
  • Check Shared per sub-folderthe box

  Generally speaking, you can keep the default settings for the rest of the options, and the modified settings are shown in the figure below:
insert image description here
  
  Then click Extract to perform feature extraction. In the case of a large amount of data, the speed of feature extraction is unstable. It may be very fast at the beginning, and several pictures can be completed in one second, and then one picture may be completed in more than ten seconds. I feel that this phenomenon may be related to the data writing speed of the database. When the extracted data is cached too much, the extraction speed will be automatically reduced, and the cache will be written into the database first. But one image in ten seconds is too slow. If the speed continues, more than 20,000 images will have to be extracted until the year of the monkey. Therefore, when the speed is relatively slow, I first interrupt the extraction process. At this time, the interface will always be stuck and unable to operate (because colmap is still writing database data), but after a period of time, I can continue to operate, and then perform feature extraction again, and the speed will be very fast again. The feature extraction of my nearly 30,000 images took a total of two or three days.
  

1.3 Feature matching

  Click Processing- Feature matchingto open the following interface:
insert image description here
  
  There are different extraction methods, among which Exhaustive is exhaustive matching, the speed is relatively slow, and it will not work when the amount of data is large. Because I am using oblique photogrammetry imagery data, the imagery is accompanied by GPS information, which can be used to guide the matching. This method is Spatial, and then you can modify max_num_neighborsthe options, which means that each image can match up to how many adjacent images. The default is 50, and I am modifying it to 200 here, which can be modified according to the actual situation. After modification, as shown in the figure below, and then click Run to run.
insert image description here
  Feature matching is also time-consuming, but the speed is relatively stable compared to feature extraction, so I didn't manually cut it off halfway, and the total time spent is two days, which is similar to feature extraction.
  

1.4 Incremental rebuild

  First some setup is required. Click Reconstruction- Reconstruction options, items that may need to be modified include:

  • multiple models: Whether to generate multiple models, the default is checked, if you don’t need colmap to rebuild multiple models, remember to uncheck this! ! ! Otherwise, you may suddenly find out after a long wait, why suddenly only so few images were reconstructed and then stopped? So I saved and closed colmap in a daze. Don't do that! ! ! (The lesson of blood and tears, I didn’t know it at the beginning, and then I just turned off the current small model and turned off colmap. Later, I found out that it was because colmap had already rebuilt the largest model, and because it was checked by default, it would continue to start a new round of reconstruction from the image that was never added, and the large model that was rebuilt before can be obtained by selecting it from the model drop-down box on the right, and then save it. I only found out after encountering this problem for the second time.
  • max_num_models: The maximum number of models, the default is 50, that is, colmap will create up to 50 different models from this data.
  • min_model_size: The number of images contained in the minimum model, the default is 10. Modify according to the requirements. By default, maybe after you get a large model, you will like to mention a lot of useless small models.

  After the setup is complete, close the options page and click Reconstruction- Start reconstructionto start rebuilding.

  

2 Database modification

  Colmap’s database can be modified directly through the database management of the UI interface, but in this way, only one cell’s data can be modified at a time. When the amount of data to be modified is large, this will be a very time-consuming and repetitive work, and errors and omissions are likely to occur. For example, when I was running data, I encountered such a problem. Originally, there were only oblique photography images of five different lenses, and the images taken by each lens were placed in different folders under the image directory. It stands to reason that there should only be five camera models, but when extracting feature points, colmap created 18 camera models for me, which is obviously wrong. Therefore, I need to modify its database file myself. There are two things to modify, one is to delete the redundant camera model in the cameras table, and the other is to correctly correspond to the camera_id in the images table. But my data contains a total of nearly 30,000 photos, and it is not realistic to manually modify each photo.
Although I am not very familiar with the operation of the database, but fortunately, this requirement is relatively simple, just search for the use of sql statements. First, we need to install the database management software sqlitebrowser (the database used by colmap is also sqlite). The installation command under ubuntu (you can go to the official website to download directly under the windows system) is:

sudo apt-get install sqlitebrowser

  After the installation is complete, continue to execute at the command line:

sqlitebrowser

  You can open the sqlitebrowser interface. Click to open the database and open the db file of colmap, as shown in the figure below:
insert image description here
  
  Open the browse data interface, and you can choose to view the data of each table, as shown in the figure below:
insert image description here
  
  double-click each cell in the table to modify the data:
insert image description here
  
  but this method is too inefficient, we can enter the SQL tab page, enter the SQL statement in it, and let the system help to modify: the meaning of the command shown in the above figure is to update the value of the camera_id field in the data whose image_id field value is less than 5527 in the images table
insert image description here
  
  . Because I have taken 5527 images for each camera, so in this way, the camera model corresponding to the image taken by the first camera can be set to the same (camera_id=1). Similarly, the camera model id modification operation of other camera images can be continued. The speed of executing SQL statements is very fast, and it only takes a few milliseconds to modify tens of thousands of data, which is not much better than manually modifying one by one.
  
  To delete redundant camera models in the cameras table, open the corresponding table directly in the data browsing interface, select the record and click the upper right corner to delete the record.
insert image description here
  After the database modification is completed, click the write modification button, or press the shortcut key ctrl+s to save.

Guess you like

Origin blog.csdn.net/weixin_44120025/article/details/130478936