I'm trying to reduce opencv2.framework size for ios. My project using only core,imgproc and highgui modules. How can I compile with only those modules? or is there an alternative for reducing size?
Thanks.
I ran into this issue now with version 3.1, and nebuto's answer is close, but not complete as of now. The following was able to produce the desired result by updating the build_framework.py file.
def getCMakeArgs(self, arch, target):
args = [
"cmake",
"-GXcode",
"-DBUILD_SHARED_LIBS=OFF",
"-DBUILD_opencv_core=ON",
"-DBUILD_opencv_imgcodecs=OFF",
"-DBUILD_opencv_imgproc=ON",
"-DBUILD_opencv_world=OFF",
"-DBUILD_opencv_gpu=OFF",
"-DBUILD_opencv_calib3d=OFF",
"-DBUILD_opencv_contrib=OFF",
"-DBUILD_opencv_features2D=OFF",
"-DBUILD_opencv_flann=OFF",
"-DBUILD_opencv_highgui=ON",
"-DBUILD_opencv_legacy=OFF",
"-DBUILD_opencv_ml=OFF",
"-DBUILD_opencv_nonfree=OFF",
"-DBUILD_opencv_objdetect=OFF",
"-DBUILD_opencv_photo=OFF",
"-DBUILD_opencv_stitching=OFF",
"-DBUILD_opencv_video=OFF",
"-DBUILD_opencv_videoio=OFF",
"-DBUILD_opencv_videostab=OFF",
"-DAPPLE_FRAMEWORK=ON",
"-DCMAKE_INSTALL_PREFIX=install",
"-DCMAKE_BUILD_TYPE=Release",
]
return args
This update also includes two new modules that appear to have not existed in 2.4.6.
For some additional savings, you can likely remove the i386 settings for simulator builds which is located at the bottom of the file. If your app is iOS 9 and above, and you wish to omit 32 bit devices, you can also take out the armv7 option as well.
b = Builder(args.opencv, args.contrib,
[
("armv7", "iPhoneOS"),
("armv7s", "iPhoneOS"),
("arm64", "iPhoneOS"),
#("i386", "iPhoneSimulator"),
("x86_64", "iPhoneSimulator"),
])
b.build(args.out)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With