编译Android平台的opencv

编译Android平台的opencv

编译流程

第一步:安装Cmake
第二步: 编写脚本configure.bat文件

cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\..\android\android.toolchain.cmake ..\..\.. -DANDROID_NDK="D:\Android\sdk\ndk-bundle" -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DCMAKE_MAKE_PROGRAM="D:\Android\sdk\ndk-bundle\prebuilt\windows-x86_64\bin\make.exe" -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi" -DANDROID_NATIVE_API_LEVEL=14 -DANDROID_FORCE_ARM_BUILD=ON -DWITH_CAROTENE=OFF -DWITH_CLP=OFF -DWITH_CUBLAS=OFF -DWITH_CUDA=OFF -DWITH_CUFFT=OFF -DWITH_EIGEN=OFF -DWITH_GDCM=OFF -DWITH_GSTREAMER_0_10=OFF -DWITH_JASPER=OFF -DWITH_JPEG=OFF -DWITH_NVCUVID=OFF -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF -DWITH_OPENEXR=OFF -DWITH_OPENMP=OFF -DWITH_OPENVX=OFF -DWITH_PNG=ON -DWITH_PTHREADS_PF=OFF -DWITH_TBB=OFF -DWITH_TIFF=OFF -DWITH_WEBP=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_ANDROID_SERVICE=OFF -DBUILD_CUDA_STUBS=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_FAT_JAVA_LIB=OFF -DBUILD_JASPER=OFF -DBUILD_JPEG=OFF -DBUILD_OPENEXR=OFF -DBUILD_PACKAGE=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_PNG=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TBB=OFF -DBUILD_TESTS=OFF -DBUILD_TIFF=OFF -DBUILD_WITH_DEBUG_INFO=OFF -DBUILD_WITH_DYNAMIC_IPP=OFF -DBUILD_opencv_apps=OFF -DBUILD_opencv_calib3d=ON -DBUILD_ZLIB=ON -DBUILD_opencv_core=ON -DBUILD_opencv_features2d=ON -DBUILD_opencv_flann=ON -DBUILD_opencv_highgui=ON -DBUILD_opencv_imgcodecs=ON -DBUILD_opencv_imgproc=ON -DBUILD_opencv_java=OFF -DBUILD_opencv_ml=ON -DBUILD_opencv_objdetect=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_shape=OFF -DBUILD_opencv_stitching=OFF -DBUILD_opencv_stereo=OFF -DBUILD_opencv_superres=OFF -DBUILD_opencv_ts=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_videoio=OFF -DBUILD_opencv_line_descriptor=OFF -DBUILD_opencv_reg=OFF -DBUILD_opencv_saliency=OFF -DBUILD_opencv_videostab=OFF -DBUILD_opencv_world=OFF -DCMAKE_CXX_FLAGS="-ffunction-sections -fdata-sections -fvisibility=hidden -O3 -std=c++11 -mfloat-abi=softfp -mfpu=neon -march=armv7-a -mtune=cortex-a8" -DCMAKE_C_FLAGS="-ffunction-sections -fdata-sections -fvisibility=hidden -O3 -mfloat-abi=softfp -mfpu=neon -march=armv7-a -mtune=cortex-a8" -DCMAKE_SHARED_LINKER_FLAGS="-Wl,--gc-sections" -DBUILD_opencv_xfeatures2d=OFF  -DBUILD_opencv_face=OFF -DBUILD_opencv_bgsegm=OFF -DBUILD_opencv_datasets=OFF -DBUILD_opencv_dpm=OFF -DBUILD_opencv_tracking=OFF -DBUILD_opencv_xobjdetect=OFF -DBUILD_opencv_optflow=OFF -DBUILD_opencv_tracking=OFF -DENABLE_NEON=ON -DOPENCV_EXTRA_MODULES_PATH="E:/opencv_contrib-3.2.0/modules" -DBUILD_opencv_ximgproc=ON -DBUILD_opencv_dnn=OFF -DBUILD_opencv_structured_light=OFF -DBUILD_opencv_surface_matching=OFF -DBUILD_opencv_text=OFF -DBUILD_opencv_xphoto=OFF -DBUILD_opencv_fuzzy=OFF -DBUILD_opencv_bioinspired=OFF -DBUILD_opencv_phase_unwrapping=OFF -DBUILD_opencv_plot=OFF -DBUILD_opencv_rgbd=OFF -DBUILD_opencv_aruco=OFF

把需要开发中需要的模块设置为“ON”,不需要的模块设置为“OFF”。
第三步:在window命令窗口中执行:configure.bat

编译Android平台的opencv_第1张图片

第四步:执行cmake –build . 命令

编译Android平台的opencv_第2张图片

第五步:执行cmake –build . –target install 命令

编译Android平台的opencv_第3张图片

至此已经编译成功了,可以到下面所示的目录找到生成的so文件

编译Android平台的opencv_第4张图片

你可能感兴趣的:(机器学习,opencv图像识别,android,opencv,编译)