OpenCV stitching in an Objective-C++ wrapper
For working in iOS, OpenCV provides its usual C++ interface that can be invoked from Objective-C++. In recent years, however, Apple has encouraged iOS application developers to use the more versatile Swift language for building applications and forgo Objective-C. Luckily, a bridge between Swift and Objective-C (and Objective-C++) can be easily created, allowing us to invoke Objective-C functions from Swift. Xcode automates much of the process, and creates the necessary glue code.
To start, we create a new file (Command-N
) in Xcode and select Cocoa Touch Class
, as shown in the following screenshot:
Choose a meaningful name for the file (for example, StitchingWrapper) and make sure to select Objective-C
as the language, as shown in the following screenshot:
Next, as shown in the following screenshot, confirm that Xcode should create a bridging header for your Objective-C code:
This process will result in three files: StitchingWrapper.h
, StitchingWrapper...