This app is based on a tutorial on using Swift and AVFoundation for extracting and displaying frames of the camera in real-time.
The tutorial was written for Swift 3, but this repo is using Swift 4.0
This project uses CocoaPods to pull in the dependency to OpenCV. A good resource for using cocoapods for opencv, and connecting the C++ library through Objective-C++ into Swift can be found here.
For a tutorial that does this without using CocoaPods, see here
I followed this tutorial which shows how to convert from a UIImage
to a cv::Mat
. In addition, I had to add the implementation for the UIImageToMat
and MatToUIImage
functions myself due to linker (ld
) errors, as described in this SO post. It's kind of seems strange that the ios_conversions.mm
has to be manually added, but it does make sense as it requires Foundation
headers and an Objective-C++ compiler. It could be better documented however... I wonder if I hadn't used CocoaPods if that source file would have been copied/compiled automatically for me.