You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
guhui@guhuideMacBook-Pro Githubs % python opencv/platforms/ios/build_framework.py ios --help
usage: build_framework.py [-h] [--opencv DIR] [--contrib DIR]
[--without MODULE] [--disable FEATURE] [--dynamic]
[--disable-bitcode]
[--iphoneos_deployment_target IPHONEOS_DEPLOYMENT_TARGET]
[--build_only_specified_archs]
[--iphoneos_archs IPHONEOS_ARCHS]
[--iphonesimulator_archs IPHONESIMULATOR_ARCHS]
[--enable_nonfree] [--debug] [--debug_info]
[--framework_name FRAMEWORK_NAME] [--legacy_build]
[--run_tests] [--build_docs] [--disable-swift]
OUTDIR
The script builds OpenCV.framework for iOS.
positional arguments:
OUTDIR folder to put built framework
optional arguments:
-h, --help show this help message and exit
--opencv DIR folder with opencv repository (default is "../.."
relative to script location)
--contrib DIR folder with opencv_contrib repository (default is
"None" - build only main framework)
--without MODULE OpenCV modules to exclude from the framework. To
exclude multiple, specify this flag again, e.g. "--
without video --without objc"
--disable FEATURE OpenCV features to disable (add WITH_*=OFF). To
disable multiple, specify this flag again, e.g. "--
disable tbb --disable openmp"
--dynamic build dynamic framework (default is "False" - builds
static framework)
--disable-bitcode disable bitcode (enabled by default)
--iphoneos_deployment_target IPHONEOS_DEPLOYMENT_TARGET
specify IPHONEOS_DEPLOYMENT_TARGET
--build_only_specified_archs
if enabled, only directly specified archs are built
and defaults are ignored
--iphoneos_archs IPHONEOS_ARCHS
select iPhoneOS target ARCHS. Default is
"armv7,armv7s,arm64"
--iphonesimulator_archs IPHONESIMULATOR_ARCHS
select iPhoneSimulator target ARCHS. Default is
"i386,x86_64"
--enable_nonfree enable non-free modules (disabled by default)
--debug Build "Debug" binaries (disabled by default)
--debug_info Build with debug information (useful for Release mode:
BUILD_WITH_DEBUG_INFO=ON)
--framework_name FRAMEWORK_NAME
Name of OpenCV framework (default: opencv2, will
change to OpenCV in future version)
--legacy_build Build legacy opencv2 framework (default: False,
equivalent to "--framework_name=opencv2
--without=objc")
--run_tests Run tests
--build_docs Build docs
--disable-swift Disable building of Swift extensions
IPHONESIMULATOR_ARCHS select iPhoneSimulator target ARCHS. Default is "i386,x86_64"
文档很清晰,默认架构没有。
尝试
python opencv/platforms/ios/build_framework.py ios --iphonesimulator_archs arm64
Using IPHONEOS_DEPLOYMENT_TARGET=9.0
Using iPhoneOS ARCHS=[u'armv7', u'armv7s', u'arm64']
Using iPhoneSimulator ARCHS=[u'arm64']
============================================================
ERROR: Cannot have the same architecture for multiple platforms in a fat framework! Consider using build_xcframework.py in the apple platform folder instead. Duplicate archs are set([u'arm64'])
============================================================
前言
上一篇已经成功在本机mac上安装opcv的库,并启动一个C++控制台程序成功调用。
但是一般我们的程序都是以app的形式作为载体的,我们需要能直接调用api并且和当前应用的界面有个“深度对接”。本来是想先从mac App,AppKit这条路来尝试的。但是opencv官网上貌似暂时只支持ios平台。所以还是先走通ios这条路再尝试mac app,毕竟ios app 和mac app有很多相似点,实在不行可以考虑通用app在macOS直接运行
获取 opencv iOS的库之路
本来以为很“简单”,摸着邓兄过河就行了。
参考资料
从官方下载iOS的库,解压zip。opencv2.framework 加入到Framworks里面,在代码里面import opencv2,敲代码也没问题。但是build以后,报错了...
一下子有点懵,剧情不是按照我想的发展啊。
难道又是我M1 arm的锅,换个思路。我直接从源代码编译出来用总行吧。“一条龙服务”总不会不支持吧
https://github.com/opencv/opencv/tree/4.x/platforms/ios/readme.txt 里面讲得还是蛮清楚的
进控制台
接下来是漫长的等待...
建议可以出去喝一杯再回来看
编译似乎没什么问题
重新引用opencv2.framework ,结果还是一样的报错
生成的sample项目编译一下也是一样的错误
一下陷入迷茫不知道怎么解决了。
还是要冷静,首先从报错关键信息入手应该是arm64-apple-ios-simulator这个关键字,打开opencv2.framework,从/Modules/opencv2.swiftmodule看确实没有arm64-apple-ios-simulator,只有“兄弟” i386-apple-ios-simulator,x86_64-apple-ios-simulator。根本就没有编译出这个架构的模块
那再回头到编译这个动作去解决
openCV 官方教程对编译库有更详细的说明
里面提到了--iphonesimulator_archs可以改架构
输入help命令看看详细说明
IPHONESIMULATOR_ARCHS select iPhoneSimulator target ARCHS. Default is "i386,x86_64"
文档很清晰,默认架构没有。
尝试
晕死,模拟器和iphone架构重复还不给执行。
不高兴去改脚本了,暂时把arm64从iphone架构阉掉,反正我先只用模拟器运行
Demo Code
storyboard拖一个button并和ViewController关联
从unsplash下一个图拖到Assets里面
}
运行结果
The text was updated successfully, but these errors were encountered: