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.
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
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.
Eigen3_DIR
to {YOUR_EIGEN3_DIRECTORY}/eigen3/cmake
.cd path/to/OpenPano
cmake .
config.cfg
to the directory containing image-stitching.exe
$ ./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.
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):
cylinder mode. Requirements:
FOCAL_LENGTH
set in config.camera estimation mode. Requirements:
translation mode. Simply stitch images together by affine transformation. Requirements:
Some options you may care:
1
in CYLINDER and TRANS mode.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.
Zijing Apartment in Tsinghua University:
"Myselves":
Carnegie Mellon University from 38 images
Newell-Simon Hall in CMU (this one is hard because objects are closer):
A full-view pano built from UAV images:
For more examples, see results.
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):
LAZY_READ
option: max(finalw * finalh * 12, #photos * w * h * 12 + #photos * #matched_pairs 96 + #keypoints 520)LAZY_READ
option: max(finalw * finalh * 16, #threads * w * h * 12, #photos * #matched_pairs 96 + #keypoints 520)For details, see my blog post.
To get the best stitching quality:
ImageRef
dist.cc
) to neon