colmap / pycolmap

Python bindings for COLMAP
BSD 3-Clause "New" or "Revised" License
858 stars 125 forks source link

Is there an Easy Debugging Method for COLMAP within Pycolmap? #242

Closed jytime closed 5 months ago

jytime commented 5 months ago

Hi all,

Thanks for your great work. I am trying to build a project on top of pycolmap (and hloc). I have successfully compiled colmap 3.9.1 and pycolmap 0.5.0 from source.

As I delve deeper, I am trying to find efficient ways to debug the code. For instance, while trying to understand the process within pycolmap.verify_matches(), I traced back to EstimateTwoViewGeometry in COLMAP. To check the H_F_inlier_ratio for various runs, I added the following logging codes:

const double H_F_inlier_ratio =
    static_cast<double>(H_report_support_num_inliers) /
    F_report_support_num_inliers;
for(int i = 0; i < 100; i++) {
    LOG(INFO) << "H_F_inlier_ratio: " << H_F_inlier_ratio;
}

However, this approach requires recompiling COLMAP from source, which takes approximately 30 minutes for each modification. I am wondering if there is a more efficient way to debug the code without having to recompile COLMAP each time. As I am relatively new to building projects with C++, I apologize if this question seems elementary. Any guidance or suggestions would be greatly appreciated.

Best Regards, Jianyuan

jytime commented 5 months ago

Okay after using the cmake command of

cmake .. -DCMAKE_CUDA_ARCHITECTURES=80 -DCMAKE_INSTALL_PREFIX=/data/home/jianyuan/ptcolmap/dependencey/colmap/build/colmap_installed/ -DCMAKE_BUILD_TYPE=Debug -DGUI_ENABLED=OFF

and only running make -j && make install for the following modifications, the re-compiling time of colmap is reduced to under a minute. Then we need to rerun "python -m pip install -e ." for pycolmap (every time after re-compiling the C++ code of colmap), which will take around 2 minutes. Although it is still a bit long, I share the command here in case someone may also need it.

sarlinpe commented 5 months ago

Using ninja can decrease the build time further: cmake .. -GNinja [...] && ninja install