Coder Social home page Coder Social logo

qinziwen / graphsfm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aibluefisher/dagsfm

1.0 1.0 0.0 93.71 MB

Robust and Efficient Graph-based Structure from Motion

Home Page: https://aibluefisher.github.io/GraphSfM/

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

CMake 0.73% C++ 33.86% C 62.37% Objective-C 0.22% Python 0.74% Shell 0.05% Makefile 0.01% MATLAB 0.14% Cuda 1.86% Batchfile 0.02% GLSL 0.01%

graphsfm's Introduction

Graph Structure from Motion (GraphSfM)

Join the chat at https://gitter.im/hlzz/libvot issues forks stars license

A similar version of GraphSfM based on OpenMVG has been released in: https://github.com/AIBluefisher/EGSfM.

1. Overview of GraphSfM

Our Structure from Motion approach, named Graph Structure from Motion (GraphSfM), is aimed at large scale 3D reconstruction. Besides, we aimed at exploring the computation ability of computer and making SfM easily transferred to distributed system. This work has been refactored, now it is based on COLMAP. We have implemented the distributed version which is based on Map-Reduce architecture.

In our work, 3D reconstruction is deemed as a divide-and-conquer problem. Our graph cluster algorithm divides images into different clusters, while images with high relativity remained in the same group. After the completion of local SfM in all clusters, an elaborate graph initialization and MST construction algorithm is designed to accurately merge clusters, and cope well with drift problems. The two proposed graph-based algorithms make SfM more efficient and robust - the graph cluster algorithm accelerate the SfM step while guarantee the robustness of clusters merging, and the MST construction makes point clouds alignment as accurate as possible. Our approach can reconstruct large scale data-set in one single machine with very high accuracy and efficiency. Based on this work, we have been successfully reconstructed Peking University within 2 hours on a laptop.

PKU

If you use this project for your research, please cite:

@misc{chen2019graphbased,
    title={Graph-Based Parallel Large Scale Structure from Motion},
    author={Yu Chen and Shuhan Shen and Yisong Chen and Guoping Wang},
    year={2019},
    eprint={1912.10659},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

@inproceedings{schoenberger2016sfm,
    author={Sch\"{o}nberger, Johannes Lutz and Frahm, Jan-Michael},
    title={Structure-from-Motion Revisited},
    booktitle={Conference on Computer Vision and Pattern Recognition (CVPR)},
    year={2016},
}

2. How to Build

2.1 Required

Basic Requirements

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
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/qchateau/rpclib.git
cd rpclib
mkdir build && cd build
cmake ..
make -j8
sudo make install

Build our GraphSfM

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

3. Usage

As our algorithm is not integrated in the GUI of COLMAP, we offer a script to run the distributed SfM (We hope there is anyone that is interested in integrating this pipeline into the GUI).

Sequential Mode

sudo chmod +x scripts/shell/distributed_sfm.sh
./distributed_sfm.sh $image_dir $num_images_ub $log_folder $completeness_ratio
  • $image_dir: The directory that stores images
  • $num_images_ub: The maximum image number in each cluster. For example, 80~120.
  • $log_folder: The directory that stores the logs
  • $completeness_ratio: The ratio that measure the repeatitive rate of adjacent clusters.

Distributed Mode

(1) At first, we need to establish the server for every worker:

cd build/src/exe
./colmap local_sfm_worker --output_path=$output_path

(2) Then, the ip and port for every server should be written in a config.txt file. The file format should follow:

server_num
ip1 port1
ip2 port2
... ...

(3) At last, start our master

# The project folder must contain a folder "images" with all the images.
DATASET_PATH=/path/to/project
CONFIG_FILE_PATH=/path/to/config.txt

./colmap distributed_mapper $DATASET_PATH/Master \
                            --database_path=$DATASET_PATH/database.db \
                            --image_path=$DATASET_PATH/images \
                            --output_path=$DATASET_PATH/Master \
                            --distributed=1 \
                            --config_file_name=$CONFIG_FILE_PATH \ 
                            --num_images_ub=$num_images_ub \
                            --graph_dir=$output_path \
                            --cluster_type=NCUT \
                            --num_workers=8

If succeed, camera poses and sparse points should be included in $DATASET/Master folder, you can use COLMAP's GUI to import it and show the visual result:

./build/src/exe/colmap gui

For small scale reconstruction, you can set the $num_images_ub equal to the number of images, the program would just use the incremental SfM pipeline of COLMAP.

For large scale reconstruction, our GraphSfM is highly recommended, these parameters should be tuned carefully: larger $num_images_ub and $completeness_ratio can make reconstruction more robust, but also may lead to low efficiency and even degenerate to incremental one.

ChangeLog

  • 2020.03.06

    • map reduce implementation for distributed Structure-from-Motion.
  • 2019.11.26

    • Image Clustering algorithms: NCut, Spectral Clustering (Upcoming)
    • Graph-based sub-reconstruction Merging algorithm

Licence

BSD 3-Clause License

Copyright (c) 2018, 陈煜
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

graphsfm's People

Contributors

aibluefisher avatar erjanmx avatar lumanyang avatar pmoulon avatar

Stargazers

Carlos Cueto avatar

Watchers

James Cloos avatar

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.