OpenCV

4.9.13

Swift Package for OpenCV
r0ml/OpenCV

What's New

OpenCV SPM Package

Every time I try to use OpenCV on an Apple platform, I lose a few days to yak shaving trying to get it to compile and including it in my project. The build process is convoluted and time-consuming -- there is no way to turn it into a Swift Package.

But now, one can create binary packages in SPM.

So here it is.

To use it, just include the package
https://github.com/r0ml/OpenCV.git

The build process (see build.sh) doesn't work with both ObjC and Swift support enabled. I chose to use --without objc. So in your project, you will need to change the setting for C++ and Objective-C interoperability to C++/Objective-C++.

Building your own version

If you wish to build your own, clone this repo (git clone --recurse-submodules).
You will need cmake installed (brew install cmake).
You will need XCode command line tools installed (xcode-select --install).
You will need to create a version of python called python installed at /usr/local/bin .
(The build scripts want an executable called python in the PATH.
Unfortunately, if you create a link to /usr/bin/python3, it will not work! )

I have included a script called python in this repo which must be copied or moved to /usr/local/bin/python.

Then run

./build.sh

The built xcframework should be located at build_xcframework/OpenCV.xcframework.

Deploying

After building the xcframework, one needs to

  1. run ./postbuild.sh xxx where xxx is the new version number of the updated package. This will update the version number in the download URL, create the release zip file, and update the checksum in Package.swift
  2. commit the changes
  3. create a tag with the above version number for this commit

LICENSE

Copyright (c) 1868 Charles Babbage
Found amongst his effects by r0ml

Description

  • Swift Tools
View More Packages from this Author

Dependencies

  • None
Last updated: Wed Nov 20 2024 22:49:15 GMT-1000 (Hawaii-Aleutian Standard Time)