kashif-izhar / OpenCVSwiftStitch

Version 2.0 of OpenCVStitch. How to stitch images using OpenCV on iOS. This version demonstrates using Swift, Objective-C and C++ together in one project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenCV computer vision with iOS: stitching panoramas

Version 2.0 of OpenCVStitch

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:
v3.0.0: available from opencv.org
v2.4.9: installed via cocoaPods

v3.0.0: download the framework and drag it to your project. Include it in the Link Binary With Libraries section of Build Phases for the target.
v2.4.9: 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.

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 2.0
Swift / Objective-C / C++
Tested with XCode 6.3 / 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
OpenCV 3.0.0 has just been released. There is no podspec avaiable, but the framework does just work if you download from http://opencv.org and drag into the project. No need for cocoaPods with this version, and the stitching runs 85% faster on my iphone 5s - but seems to produce less accurate results.

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 7

The project is not yet updated for XCode 7, so there are minor issues that you may encounter with XCode 7, ios9 and Swift 2. In particular, if you open the project in XCode 7, you will be asked if you want to convert to the latest Swift syntax. You do not have to do this to run the project. If you do convert, the update will also turn on Bitcode. Then the project will not compile, as the openCV framework is not bitcode-enabled.

You can disable Bitcode by setting the projects's build settings->build options->Enable Bitcode switch to NO.

Comparisons

OpenCV 2.4.9OpenCV 3.0.0
v2_inset2 v2_inset2
v2_inset2 v2_inset2

About

Version 2.0 of OpenCVStitch. How to stitch images using OpenCV on iOS. This version demonstrates using Swift, Objective-C and C++ together in one project.

License:Other


Languages

Language:Objective-C++ 34.9%Language:C++ 30.7%Language:Swift 26.2%Language:Objective-C 7.4%Language:Ruby 0.8%