ppwwyyxx / OpenPano

Automatic Panorama Stitching From Scratch
MIT License
1.85k stars 552 forks source link
bundle-adjustment panorama sift

OpenPano

cmu0

Introduction

OpenPano is a panorama stitching program written in C++ from scratch (without any vision libraries). It mainly follows the routine described in the paper Automatic Panoramic Image Stitching using Invariant Features, which is also the one used by AutoStitch.

Installation

We need the following dependencies:

Eigen, CImg and FLANN are header-only, to simplify the compilation on different platforms. CImg and libjpeg are only used to read and write images, so you can easily get rid of them.

On ArchLinux, install dependencies by: sudo pacman -S gcc sed cmake make libjpeg eigen

On Ubuntu, install dependencies by: sudo apt install build-essential sed cmake libjpeg-dev libeigen3-dev

Compile:

Linux / OSX / WSL (bash on windows)

Use cmake (a good default to try):

$ cmake -B build && make -C build
# Binary will be found at ./build/src/image-stitching

or, use make (more customizable. You can modify Makefile when you run into problems.):

$ make -C src
# Binary will be found at ./src/image-stitching

The default clang on OSX doesn't contain openmp support. You may need gcc or different clang. See #16.

Windows (for VS2015)

Usage

$ ./image-stitching <file1> <file2> ...

The output file is out.jpg. You can play with the example data to start with.

Before dealing with very large images (4 megapixels or more), it's better to manually downscale them to save time.

In cylinder/translation mode, the input file names need to have the correct order.

Configuration:

The program expects to find the config file config.cfg in the working directory. Three modes are available (set/unset them in the top of the config file):

Some options you may care:

Other parameters are quality-related. The default values are generally good for images with more than 0.7 megapixels. If your images are too small and cannot produce satisfactory results, it might be better to resize your images rather than tune the parameters.

Examples (All original data available for download)

Zijing Apartment in Tsinghua University: dorm

"Myselves": myself

Carnegie Mellon University from 38 images apple

Newell-Simon Hall in CMU (this one is hard because objects are closer): nsh

A full-view pano built from UAV images: uav

For more examples, see results.

Speed & Memory

Tested on Intel Core i7-6700HQ, with ESTIMATE_CAMERA mode:

Memory consumption is known to be huge with default libc allocator. Simply using a modern allocator (e.g. tcmalloc, jemalloc) can help a lot. Also, setting LAZY_READ to 1 can save memory at the cost of a minor slow down.

Peak memory in bytes (assume each input has the same w & h):

Algorithms

For details, see my blog post.

Quality Guidelines

To get the best stitching quality:

TODOs