Code Monkey home page Code Monkey logo

opencvswiftstitch's Introduction

OpenCV computer vision with iOS: stitching panoramas

Version 4.0 of OpenCVStitch - updated for Swift 4.2
See appropriate branches and tags for Swift 2.x - 3.x

This project was created to a answer a couple of Stack Overflow questions:
libraries to CAPTURE panorama in iOS
Can I mix Swift with C++? Like the Objective - C .mm files

v2 demonstrates how to mix Swift, Objective-C and C++ in one project whilst keeping the code clearly separate.

The project AppDelegate and View Controller are written in Swift. Swift cannot talk directly to C++ (which we need for OpenCV), so we provide an Objective-C++ wrapper class to mediate between Swift and C++. We also provide an Objective-C++ category on UIImage to mediate between UIImage and CV::Mat image formats. The CVWrapper header file is pure Objective-C. For v1(which doesn't use Swift) this separation was a matter of clean style. For v2, it is a requirement: if any C++ headers are included in the wrapper, the app will not compile (Swift won't like it).

Installation
To run the project you need to install the OpenCV framework using Cocoapods

Assuming you have first installed CocoaPods, run 'pod install' in this directory to install OpenCV for the project. From then on, always open the project in XCode from the SwiftStitch.xcworkspace file that the pod install creates.

v3.1.0: The default podfile will install openCV v3.1.0, with a hotfix for arm64 compataibility

v2.4.9: Recomment the podfile:
pod 'OpenCV', '2.4.9-zp'
#pod 'OpenCV', '~> 3.1.0.1'
Change the #include line for 2.4.9 compatibility as indicated in stitching.cpp

Use
OpenCVStitch is a very simple iOS/openCV example showing basic use of the Stitcher class. The c++ code is adapted from a sample included with the openCV distribution.

The app has almost no user interface. On launch, the stitching code operates on four sample images, displaying the result in a UIScrollView.

OpenCVStitch Versions
Version 4.0
Swift / Objective-C / C++
Tested with XCode 10.0 / Swift 4.2 for iOS 8.0+
Version 3.0
Swift / Objective-C / C++
Tested with XCode 8.0 / Swift 3.0 for iOS 8.0+
Version 2.1
Swift / Objective-C / C++
Tested with XCode 7.0 / Swift 2.0 for iOS 7.0+
Version 2.0
Swift / Objective-C / C++
Tested with XCode 6.4 / Swift 1.2 for iOS 7.0+
Version 1.0
Objective-C / C++
Tested with XCode 4.5.2 -> 6.3 for iOS 5.1 upwards

Provides a partial answer to: Libraries to capture panoramas in iOS 6 (Stack Overflow)

OpenCV Versions
OpenCV 3.x
The podfile installs a hotfixed version of 3.1 as the prebuilt binary provided by openCV breaks on arm64 devices.

The stitching seems to be much more efficient (85% faster on my iphone 5s). However the quality is noticeably inferior with the test images supplied, so v2.4x remains the default for now [some improvement with openCV 3.1].

OpenCV 2.4.x
The openCV distribution is not as clean as we would like.
2.4.10 - the pod spec and the distribution build for iOS is broken
2.4.9 - the pod spec is broken. This is likely a result of relying on Sourceforge for hosting.

Therefore we are using a self-hosted podspec (thanks Matteo!) until official channels are fixed. Specs are available for 2.4.9 and 2.4.10, but as the latter won't run we use 2.4.9.

this version of OpenCVStitch opted to use cocoapods to overcome the notorious installation issues with previous versions of the openCV 2.4.x framework.. it seems our optimism was slightly premature!

XCode 10

Project is now updated for Swift 4.1 and XCode 10. For backwards compatibility checkout the 2.0 / 2.1 branches, 3.0 release or refer to the Objective-C version v1.0.

Comparisons

OpenCV 2.4.9OpenCV 3.0.0OpenCV 3.1.0
v2_inset2 v2_inset2 v2_inset2
v2_inset2 v2_inset2 v2_inset2

opencvswiftstitch's People

Contributors

foundry avatar rinatkhanov avatar robmurrer avatar

Watchers

Adam Winczewski 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.