cmake编译iOS/android/mac的opencv库
程序员文章站
2022-03-27 20:41:52
编译环境操作系统:Mac OS X 10.15.4 (19E266)XCode :Version 11.4 (11E146)cmake :cmake version 3.10.2python:3.7.4_1准备工作1、下载源码// 下载opencv_master源码git clone https://github.com/opencv/opencv.git opencv_mastergit checkout -b my-4.3.0 4.3.0// 下载opencv_....
编译环境
- 操作系统:Mac OS X 10.15.4 (19E266)
- XCode :Version 11.4 (11E146)
- cmake :cmake version 3.10.2
- python:3.7.4_1
准备工作
1、下载源码
// 下载opencv_master源码
git clone https://github.com/opencv/opencv.git opencv_master
git checkout -b my-4.3.0 4.3.0
// 下载opencv_contrib源码
git clone https://github.com/opencv/opencv_contrib.git opencv_contrib
git checkout -b my-4.3.0 4.3.0
2、安装指定cmake版本和python版本
旧版本cmake
旧版本python
opencv for mac编译及使用步骤
- 更改脚本
由于脚本是基于python2写的,为了兼容python3,这里需要更改脚本,否则提示
"ERROR: cannot use a string pattern on a bytes-like object"
1、将脚本platforms/ios/build_framework.py中的代码改成如下:
更改前
ret = check_output(["xcodebuild", "-version"])
更改后
encoding = 'utf-8'
ret = check_output(["xcodebuild", "-version"]).decode(encoding)
- 编译命令
python3 platforms/osx/build_framework.py --contrib=../opencv_contrib ../output/macosx
等待数分钟,默认将生成动态库
image.png
-
使用
拖进工程中image.png
配置framework路径
image.png
如果提示如下错误:
......
"_clCreateProgramWithSource", referenced from:
.....
添加如下依赖库:
Accelerate.framework
OpenCL.framework
CoreMedia.framework
libopenjp2.a
QuartzCore.framework
AVFoundation.framework
libc++.tbd
CoreGraphics.framework
CoreImage.framework
CoreVideo.framework
Foundation.framework
opencv for iOS编译及使用步骤
opencv for android编译及使用步骤
本文地址:https://blog.csdn.net/qq_21743659/article/details/109379972