windows下CMake交叉编译Android环境OpenCV(为了加入ffmpeg)

参考博客:
https://www.jianshu.com/p/550c85024c49
https://blog.csdn.net/airgreen/article/details/108944582

1.下载opencv源码
2.为了编译时加入ffmpeg,按博客1所说的方式修改两个文件
3.编译opencv

cmake -G "Unix Makefiles"  -DBUILD_ANDROID_PROJECTS=OFF -DCMAKE_MAKE_PROGRAM="D:/Qt5.11.3/Tools/mingw530_32/bin/mingw32-make.exe" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DANDROID_NDK="D:/android-ndk-r15c" -DANDROID_SDK="D:\SDK\adt-bundle-windows-x86_64-20140702\sdk" -DCMAKE_TOOLCHAIN_FILE=D:/android-ndk-r15c/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=22 -DANDROID_ABI=armeabi-v7a -DANDROID_CPP_FEATURES="rtti exceptions" -DANDROID_ARM_NEON=TRUE -DANDROID_TOOLCHAIN=gcc -DANDROID_STL=c++_shared -DBUILD_SHARED_LIBS=ON -DANDROID_PLATFORM=android-22 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="../install_dynamic/android/armeabi-v7a/" -DBUILD_opencv_java=OFF -DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_DOCS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DWITH_CUDA=OFF -DWITH_MATLAB=OFF -DWITH_TIFF=OFF -DWITH_FFMPEG=ON -DBUILD_opencv_dnn=OFF -DBUILD_opencv_objdetect=OFF -DBUILD_opencv_stitching=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_ml=OFF -DBUILD_opencv_dnn=OFF -DBUILD_opencv_features2d=OFF -DBUILD_opencv_flann=OFF ..

编译动态库:

-DANDROID_STL=c++_shared -DBUILD_SHARED_LIBS=ON

编译静态库:

-DANDROID_STL=c++_static -DBUILD_SHARED_LIBS=OFF

遇到std::cbrt问题:
可以把出现问题的地方直接注调:

//#ifdef CV_CXX11
//    return std::cbrt(val);
//#else
    double v = pow(abs(val), 1/3.);  // pow doesn't support negative inputs with fractional exponents
    return val >= 0 ? v : -v;
//#endif

你可能感兴趣的:(opencv,android,opencv,windows)