colmap / colmap

COLMAP - Structure-from-Motion and Multi-View Stereo
https://colmap.github.io/
Other
7.06k stars 1.44k forks source link

Export Dense Point Cloud as Points3D.bin from Command Line #738

Open boitumeloruf opened 4 years ago

boitumeloruf commented 4 years ago

Is there a possibility to export and save the dense point cloud in a points3d.bin file when calling stereo_fusion from the command line?

I want to perform a geo registration of the dense point cloud by fully using the command line interface of colmap. So far I use the GUI to import the .ply file and export it into the .bin file before calling the model_aligner. As far as I understand it so far the model_aligner cannot work on the .ply file.

I want to deploy colmap onto a headless compute server which is why I cannot rely on the GUI.

Thanks for your help...

tsattler commented 4 years ago

There is no such functionality since the points3D.bin file stores a lot of information that is not directly available in the dense point clouds (corresponding feature descriptors, which images see a 3D point, etc.). Why not first align the 3D model that colmap produces before dense reconstruction?

boitumeloruf commented 4 years ago

But I can export the dense model via the GUI as points3D.bin.

I have already tried to align the model with the sparse reconstruction and then perform the dense reconstruction with the aligned data. But this failes, especially in the fusion step, or gives me very poor results.

tsattler commented 4 years ago

You are right, Colmap can indeed export the dense point cloud to .bin files.

Please note that the model_aligner aligns a set of camera poses (defined in images.bin) with a set of reference poses. The model that I got when exporting the dense point cloud to .bin files neither included cameras nor images. As such, I would expect the model_aligner to fail. You could try and see what happens if you use the corresponding image and camera files, e.g., from the sparse/ subdirectory of the directory you use for dense reconstruction, for the alignment step. Not sure what will happen though.

boitumeloruf commented 4 years ago

Thanks for the reply.

Yes I have to use the cameras.bin and images.bin file from the sparse reconstruction. Together with the point3D.bin file form the dense reconstruction the model_aligner succeeds.

However, I still have a problem in creating a points3D.bin file for the dense reconstruction without using the gui. I suppose that currently there is no such feature to create such file from the command line. Is that correct?

tsattler commented 4 years ago

Since I did not even know that Colmap can export a dense reconstruction via the gui, I am probably the wrong person to ask. My guess is actually that this is not intended behavior but probably comes from representing the dense point cloud in a way that can be handled by the rendering thread.

I'd recommend to check the source code whether there is the functionality to export ply files to bin file and if not write the corresponding code yourself.

boitumeloruf commented 4 years ago

Thank you. I will check.

boitumeloruf commented 4 years ago

I have checked the source code and there was no such functionality.

So I have implemented it as a new feature to the stereo_fusion, when called from the command line. I issued a pull request: https://github.com/colmap/colmap/pull/799 Please integrate it into the main repository.

As stated in the beginning, this functionality is important to allow for using model_aligner in a headless workflow (e.g. when deployed on a compute server).