GitXplorerGitXplorer
p

OpenPano

public
1905 stars
554 forks
35 issues

Commits

List of commits on branch master.
Verified
f9b246945e891b67e200def47e399bf591422c9e

add github actions (#133)

pppwwyyxx committed a year ago
Unverified
ed7f73de867fa8160970b4cc8346b79c3b0a1750

Update readme

pppwwyyxx committed a year ago
Unverified
3b90259c84426895e5184e52ddaf352a1f107859

Build process overhaul

pppwwyyxx committed a year ago
Verified
ca1b86f6133c0f1ead82280f1a8355ff2711c5dc

Compatible with Python 3, using .so instead of .a (#125)

jjiapei100 committed 2 years ago
Verified
e27b1c4dfe53bb78fdde2faeadeba28927134b87

Update README.md (#121)

IIdanCo committed 3 years ago
Unverified
8d97af7193210e478c5a28013bdf63e38ebffc7e

update readme

pppwwyyxx committed 3 years ago

README

The README file for this repository.

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:

  • gcc >= 5, clang >= 10 or visual studio >= 2015. CMake >= 3.20
  • Eigen
  • libjpeg (optional, if you only need png format)
  • FLANN (already included in the repository, slightly modified)
  • CImg (optional. already included in the repository)

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)

  • Install cmake, VS2015
  • Set environment variable Eigen3_DIR to {YOUR_EIGEN3_DIRECTORY}/eigen3/cmake.
  • Open Visual Studio Developer Command Prompt.
  • cd path/to/OpenPano
  • cmake .
  • Open the VS2015 project and compile the project
  • copy config.cfg to the directory containing image-stitching.exe
  • The author have never used Visual Studio and this windows build process may not work for you. Feel free to submit PR to improve the build process.

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):

  • cylinder mode. Requirements:

    • You stay at the same spot and only turn left (or right) when taking the images (as is usually done), no translations or other type of rotations allowed.
    • Images are taken with the same camera, with a known FOCAL_LENGTH set in config.
    • Images are given in the left-to-right order. (I might fix this in the future)
  • camera estimation mode. Requirements:

    • You stay at the same spot when taking the images, and can turn your camera left-right or up-down.
    • Don't use too few images.
    • It runs slower because it needs to perform pairwise matches.
  • translation mode. Simply stitch images together by affine transformation. Requirements:

    • Camera performs pure translation.
    • The images are roughly at the same depth.
    • Input images are ordered according to the translation movement.

Some options you may care:

  • FOCAL_LENGTH: focal length of your camera in 35mm equivalent. Only useful in cylinder mode.
  • ORDERED_INPUT: whether input images are ordered sequentially. has to be 1 in CYLINDER and TRANS mode.
  • CROP: whether to crop the final image to avoid irregular white border.

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: 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:

  • 11 ordered images of size 600x400: 3.2s.
  • 13 ordered images of size 1500x1112: 6s.
  • 38 unordered images of size 1300x867 (high vertical FOV): 51s.

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):

  • Without LAZY_READ option: max(finalw * finalh * 12, #photos * w * h * 12 + #photos * #matched_pairs * 96 + #keypoints * 520)
  • With LAZY_READ option: max(finalw * finalh * 16, #threads * w * h * 12, #photos * #matched_pairs * 96 + #keypoints * 520)

Algorithms

  • Features: SIFT
  • Transformation: use RANSAC to estimate a homography or affine transformation.
  • Optimization: focal estimation, bundle adjustment, and some straightening tricks.

For details, see my blog post.

Quality Guidelines

To get the best stitching quality:

  • While rotating the camera for different shots, try to keep the position of camera lens static.
  • Keep the exposure parameters unchanged.
  • Do not shoot on moving objects.
  • Objects far away will stitch better.
  • The algorithm doesn't work well with wide-angle cameras where images are distorted heavily. Camera parameters are needed to undistort the images.

TODOs

  • Github Actions for macOS and Windows
  • apply pairwise matching for translation mode as well
  • run bundle adjustment on sphere lens instead of perspective lens
  • improve feature detector and matching
  • use LAZY_READ & 1 byte image in both blender to reduce peak memory
  • clean up use of copies of ImageRef
  • faster gaussian blur kernel
  • port some hotspot (e.g. dist.cc) to neon
  • support read/write EXIF metadata to:
    • get focal length, distortion, etc
    • allow pano to be viewed on Facebook
  • python bindings