2014-11-27 20:39:05 +08:00
Installation in iOS {#tutorial_ios_install}
===================
2020-05-20 06:59:28 +08:00
@prev_tutorial {tutorial_macos_install}
@next_tutorial {tutorial_arm_crosscompile_with_cmake}
2020-10-08 05:35:06 +08:00
| | |
| -: | :- |
| Original author | Artem Myagkov, Eduard Feicho, Steve Nicholson |
| Compatibility | OpenCV >= 3.0 |
@warning
This tutorial can contain obsolete information.
2014-11-27 20:39:05 +08:00
Required Packages
-----------------
- CMake 2.8.8 or higher
- Xcode 4.2 or higher
### Getting the Cutting-edge OpenCV from Git Repository
2019-11-23 07:38:53 +08:00
Launch Git client and clone OpenCV repository from [GitHub ](http://github.com/opencv/opencv ).
2014-11-27 20:39:05 +08:00
In MacOS it can be done using the following command in Terminal:
2014-11-28 00:54:13 +08:00
2014-11-27 20:39:05 +08:00
@code {.bash}
cd ~/< my_working _directory >
2016-06-14 21:01:36 +08:00
git clone https://github.com/opencv/opencv.git
2014-11-27 20:39:05 +08:00
@endcode
2014-11-28 00:54:13 +08:00
2019-11-23 07:38:53 +08:00
If you want to install OpenCV’ s extra modules, clone the opencv_contrib repository as well:
@code {.bash}
cd ~/< my_working _directory >
git clone https://github.com/opencv/opencv_contrib.git
@endcode
2014-11-27 20:39:05 +08:00
Building OpenCV from Source, using CMake and Command Line
---------------------------------------------------------
2019-11-23 07:38:53 +08:00
1. Make sure the xcode command line tools are installed:
2014-11-27 20:39:05 +08:00
@code {.bash}
2019-11-23 07:38:53 +08:00
xcode-select --install
2014-11-27 20:39:05 +08:00
@endcode
2014-11-28 00:54:13 +08:00
2019-11-23 07:38:53 +08:00
2. Build OpenCV framework:
2014-11-27 20:39:05 +08:00
@code {.bash}
cd ~/< my_working_directory >
python opencv/platforms/ios/build_framework.py ios
@endcode
2014-11-28 00:54:13 +08:00
2019-11-23 07:38:53 +08:00
3. To install OpenCV’ s extra modules, append `--contrib opencv_contrib` to the python command above. **Note:** the extra modules are not included in the iOS Pack download at [OpenCV Releases ](https://opencv.org/releases/ ). If you want to use the extra modules (e.g. aruco), you must build OpenCV yourself and include this option:
@code {.bash}
cd ~/< my_working_directory >
python opencv/platforms/ios/build_framework.py ios --contrib opencv_contrib
@endcode
4. To exclude a specific module, append `--without <module_name>` . For example, to exclude the "optflow" module from opencv_contrib:
@code {.bash}
cd ~/< my_working_directory >
python opencv/platforms/ios/build_framework.py ios --contrib opencv_contrib --without optflow
@endcode
5. The build process can take a significant amount of time. Currently (OpenCV 3.4 and 4.1), five separate architectures are built: armv7, armv7s, and arm64 for iOS plus i386 and x86_64 for the iPhone simulator. If you want to specify the architectures to include in the framework, use the `--iphoneos_archs` and/or `--iphonesimulator_archs` options. For example, to only build arm64 for iOS and x86_64 for the simulator:
@code {.bash}
cd ~/< my_working_directory >
python opencv/platforms/ios/build_framework.py ios --contrib opencv_contrib --iphoneos_archs arm64 --iphonesimulator_archs x86_64
@endcode
If everything’ s fine, the build process will create
`~/<my_working_directory>/ios/opencv2.framework` . You can add this framework to your Xcode projects.
2014-11-27 20:39:05 +08:00
Further Reading
---------------
2014-11-28 00:54:13 +08:00
You can find several OpenCV+iOS tutorials here @ref tutorial_table_of_content_ios.