Coder Social home page Coder Social logo

aibluefisher / graphoptim Goto Github PK

View Code? Open in Web Editor NEW
148.0 9.0 22.0 14.05 MB

The official implementation of our CVPR 2021 paper - Hybrid Rotation Averaging: A Fast and Robust Rotation Averaging Approach

License: BSD 3-Clause "New" or "Revised" License

CMake 9.46% C++ 90.05% Shell 0.49%

graphoptim's Introduction

Graph Optimizer

Build Status License

This repo contains the official implementation of our CVPR 2021 paper - Hybrid Rotation Averaging: A Fast and Robust Rotation Averaging Approach. This library contains not only rotation averaging solvers, but also some popular methods in 3D vision, such as translation averaging, clustering, etc. The library is designed to deal with large scale optimization problems, and is easy to extend. Feel free to contribute to this project.

1. Features

  • A library which solves the optimization problems in 3D vision.
  • A template-based graph module which is easy to extend and to manipulate graph structures.
  • Rotation averaging solvers achieves state-of-the-art.
  • Translation averaging solvers (LUD, LiGT, BATA).
  • Global SfM pipeline

2. Compilation

The library is compiled and tested on Ubuntu 16.04/18.04/20.04. We would like to support more platforms in the future.

2.1 Basic Requirements

This project requires Eigen 3.2. And Ceres 1.14.0 is currently used for nonlinear optimization. You can install all the dependencies through the ./scripts/dependencies.sh.

bash ./scripts/dependencies.sh

2.3 Build GraphOptim

Follow build.sh or execute the command below:

git clone https://github.com/AIBluefisher/GraphOptim.git
cd GraphOptim
mkdir build && cd build
cmake ..
make -j8
sudo make install

2.4 Build GlobalSfM

Once we installed GraphOptim, we can use it as an external library. And also, we can try the provided global SfM application.

At first, try to install my folk of COLMAP. Then main difference between this folk and COLMAP is that my folk stores relative poses into the database while COLMAP does not.

# COLMAP dependencies
sudo apt-get install \
    git \
    cmake \
    build-essential \
    libboost-program-options-dev \
    libboost-filesystem-dev \
    libboost-graph-dev \
    libboost-regex-dev \
    libboost-system-dev \
    libboost-test-dev \
    libeigen3-dev \
    libsuitesparse-dev \
    libfreeimage-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    libglew-dev \
    qtbase5-dev \
    libqt5opengl5-dev \
    libcgal-dev \
    libcgal-qt5-dev

# ceres-solver
sudo apt-get install libatlas-base-dev libsuitesparse-dev
git clone https://ceres-solver.googlesource.com/ceres-solver
cd ceres-solver
git checkout $(git describe --tags) # Checkout the latest release
mkdir build
cd build
cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF
make
sudo make install

git clone https://github.com/AIBluefisher/colmap
cd colmap
mkdir build && cd build
cmake .. && make -j8
sudo make install

Then, we can build GlobalSfM pipeline by checking into the applications subfolder:

cd applications
mkdir build && cd build
cmake ..
make -j8

3. Running Examples

3.1 Rotation Averaging

./build/bin/rotation_estimator --g2o_filename=./data/synthetic/20_2.g2o

You can also try other g2o files.

3.2 Translation Averaging

The translation averaging methods are decoupled from another project.

./build/bin/position_estimator --g2o_filename=./data/synthetic/20_2.g2o

3.3 Global Structure from Motion

COLMAP provides only incremental Structure-from-Motion pipelines. To mitigate this issue, we implement a global SfM pipeline based on TheiaSfM. The implementation can provide a fair comparison to other methods, since most work uses COLMAP's keypoints and feature matcher while TheiaSfM uses different keypoints extraction and matching method, which is not suitable to do a fair comparison.

./applications/run_global_sfm.sh $DATASET_PATH $OUTPUT_PATH $VOC_TREE_PATH $MOST_SIMILAR_IMAGES_NUM

You may also want to try different rotation averaging and translation averaging solvers by setting (just appending the parameters at the end of your command):

It is recommended to use LIGT as the translation averaging solver, as it performs always better than LUD in the test. Tests are based on the dataset collected by Olsson:

Alcatraz_courtyard [Click to view results]

pumpkin [Click to view results]

Sri Mariamman [Click to view results]

3.4 View Graph Synthesize

GraphOptim also supports to generate a synthesized dataset to train SOTA pose synchronization models. Implementation is adapted from NeuRoRa's matlab code.

./build/bin/view_graph_synthesizer \
  --num_threads=8 \
  --num_scenes=1250 \
  --output_dir=./

4. Use GraphOptim as a 3rd-party library

find_package(Gopt REQUIRED)
if(GOPT_FOUND)
  message(STATUS "Found GOPT_INCLUDE_DIRs ${GOPT_INCLUDE_DIRS}")
  message(STATUS "Found GOPT_LINK_DIRs ${GOPT_LINK_DIRS}")
  message(STATUS "Found GOPT_LIBRARIES ${GOPT_LIBRARIES}")
else(GOPT_FOUND)
  message(FATAL "GOPT not found!")
endif(GOPT_FOUND)

include_directories(${GOPT_INCLUDE_DIRS})
link_directories(${GOPT_LINK_DIRS})

add_library(${YOUR_LIB} *.h *.cc)
target_link_libraries(${YOUR_LIB} ${GOPT_LIBRARIES})

add_executable(${YOUR_EXE} *.h *.cc)
target_link_libraries(${YOUR_EXE} ${GOPT_LIBRARIES})

Citation

If you find the code useful for your research, please consider cite our paper:

@inproceedings{DBLP:conf/cvpr/Chen0K21,
  author    = {Yu Chen and
               Ji Zhao and
               Laurent Kneip},
  title     = {Hybrid Rotation Averaging: {A} Fast and Robust Rotation Averaging
               Approach},
  booktitle = {{IEEE} Conference on Computer Vision and Pattern Recognition},
  pages     = {10358--10367},
  year      = {2021}
}

graphoptim's People

Contributors

aibluefisher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphoptim's Issues

Inputs of Translation Averaging Need Absolute Rotation of Each View and Relative Pose of Piar Views

Hi,
Thanks your great work!
There is a bug in your code:
Description:
Inputs of Translation Averaging Need Absolute Rotation of Each View and Relative Pose of View Pair ,
But in examples/position_estimator.cc: 56 view_graph.ReadG2OFile(g2o_filename);
you only convey relative rotation and relative translation.

So, the following codes need to be corrected:

edge.cc:
replace :
// node_t src = kInvalidNodeId;
// node_t dst = kInvalidNodeId;
with:
ImageNode src;
ImageNode dst;
and correct construction fun correspondingly,
view_graph.cc:
ViewGraph::ReadG2OFile, add absolute rotation to edge.src and edge.dst.
graph.inl:
correct AddEdge and AddNodes etc.
and some test functions.

OpenMVG related code in this repo

Thank you for releasing the code related to your paper.

I noticed that there are multiple files that are coming from OpenMVG code repository.

Topic This Repo OpenMVG
SVG https://github.com/AIBluefisher/GraphOptim/blob/main/src/graph/svg_drawer.h https://github.com/openMVG/openMVG/blob/develop/src/third_party/vectorGraphics/svgDrawer.hpp
triplet https://github.com/AIBluefisher/GraphOptim/blob/main/src/graph/triplet_extractor.h https://github.com/openMVG/openMVG/blob/develop/src/openMVG/graph/triplet_finder.hpp
ColorGradient https://github.com/AIBluefisher/GraphOptim/blob/main/src/graph/color_gradient.h https://github.com/openMVG/openMVG/blob/develop/src/openMVG/graphics/color_gradient.hpp
l1 solver https://github.com/AIBluefisher/GraphOptim/blob/main/src/solver/l1_solver.h https://github.com/openMVG/openMVG/blob/develop/src/openMVG/numeric/l1_solver_admm.hpp
...

There are also other files that have the same issue
https://github.com/AIBluefisher/GraphOptim/blob/main/src/util/alignment.h ...

There is also code from other repositories like THeiaSfM here https://github.com/sweeneychris/TheiaSfM/blob/master/src/theia/sfm/global_pose_estimation/least_unsquared_deviation_position_estimator.h
https://github.com/AIBluefisher/GraphOptim/blob/main/src/translation_averaging/lud_position_estimator.h

Please keep the initial copyright notice and respect the work that has been done by the open-source community before you.
Changing the name of the file is not enough to claim ownership of it.

I appreciate that you see the direct value of OpenMVG code and are leveraging it for other work, but the opensource community can thrive better if we support each other, and keep initial copyrights and licenses in the file we are reusing.

cc @laurentkneip

rotation_estimator std::bad_alloc

@AIBluefisher
HI,when I run the rotation_estimator ,the error like this:
./build/bin/rotation_estimator --g2o_filename=./data/synthetic/20_2.g2o I0120 19:03:26.052269 18845 hybrid_rotation_estimator.cc:94] Estimating Rotations Using LagrangeDual terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped)
also when I run the ./lagrange_dual_rotation_estimator_test
dual_rotation_estimator_test Running main() from gtest_main.cc [==========] Running 15 tests from 1 test case. [----------] Global test environment set-up. [----------] 15 tests from LagrangeDualRotationAveragingTest [ RUN ] LagrangeDualRotationAveragingTest.smallTestNoNoise WARNING: Logging before InitGoogleLogging() is written to STDERR I0120 19:07:51.680837 19045 lagrange_dual_rotation_estimator_test.cc:88] Estimating Global Orientations using Lagrange Dual... free(): invalid pointer Aborted (core dumped)

COLMAP/Global SfM Support

It aims at using COLMAP as a multiview codebase, then using this library to estimate global camera poses.

使用官方colmap运行结果不一致

你好,我在使用官方colmap生成database信息并提供了relative poses后,然后用run_global_mapper.cc进行重建时,让系统输出camera.bin、images.bin和point3d.bin后用colmap gui查看发现位姿态结果和直接使用您的colmap配合run_global_mapper.cc进行重建输出的.bin文件展现的位姿结果不一样,请问有什么头绪吗?

代码中是否有LIGT-PA的实现?

LIGT算法论文中有提到 rotation average 和LIGT完成后,会有一个PA(pose adjustment)的可选的过程,请问本代码中是不是并没有实现

$VOC_TREE_PATH $MOST_SIMILAR_IMAGES_NUM

你好,小白问一下这两个参数分别指的是什么?第一个时词典路径还是指什么?需要是什么格式呢?后一个参数是随便设置吗?

关于global_sfm分支application编译中colmap问题

作者你好,我按照你给的global_sfm步骤,已成功完成GraphOptim的编译安装,但是在编译application时遇到colmap版本问题,想请问一下作者使用的是哪个版本的colmap。谢谢。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.