Android平台OpenGL ES/Assimp/OpenCV/GLM集成说明

下载Assimp 5.0.1版本:https://codeload.github.com/assimp/assimp/zip/refs/tags/v5.0.1

解压后本地目录为D:\Code\temp\assimp-5.0.1

将scripts\android_crosscompile\make_android.bat拷贝为scripts\android_crosscompile\make_android_self_defined.bat

将scripts\android_crosscompile\make_android_self_defined.bat中的内容进行自定义配置,我的配置如下:

@echo off set ASSIMP_PATH=D:\Code\temp\assimp-5.0.1 set CMAKE_PATH="C:\Users\jiangxin\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe" set ANDROID_NDK_PATH=C:\Users\jiangxin\AppData\Local\Android\Sdk\ndk\22.0.7026061 set ANDROID_CMAKE_PATH=C:\Users\jiangxin\AppData\Local\Android\Sdk\ndk\22.0.7026061\build\cmake pushd %ASSIMP_PATH% rmdir /s /q build mkdir build cd build %CMAKE_PATH% .. ^ -G"MinGW Makefiles" ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_CXX_FLAGS_RELEASE="%CMAKE_CXX_FLAGS_RELEASE% -Os -Wall -s" ^ -DCMAKE_TOOLCHAIN_FILE=%ANDROID_CMAKE_PATH%\android.toolchain.cmake ^ -DCMAKE_MAKE_PROGRAM=%ANDROID_NDK_PATH%\prebuilt\windows-x86_64\bin\make.exe ^ -DANDROID_NDK=%ANDROID_NDK_PATH% ^ -DANDROID_NATIVE_API_LEVEL=android-16 ^ -DASSIMP_ANDROID_JNIIOSYSTEM=ON ^ -DANDROID_ABI=arm64-v8a ^ -DASSIMP_BUILD_ZLIB=ON ^ -DASSIMP_BUILD_TESTS=OFF ^ -DASSIMP_BUILD_ASSIMP_TOOLS=OFF ^ -DASSIMP_NO_EXPORT=ON %CMAKE_PATH% --build . popd

执行如下编译命令:

cd D:\Code\temp\assimp-5.0.1\scripts\android_crosscompile .\make_android_self_defined.bat

将assimp-4.1.0\build\codelibassimp.so放到app\libs\

将assimp-4.1.0\include中的目录放到app\src\main\cpp\include

将assimp-4.1.0\build\include\assimp\config.h拷贝到app\src\main\cpp\assimp-4.1.0\include\assimp

集成OpenCV

OpenCV的集成比较简单,官网提供了Android平台所需的动态库和C++头文件。

下载OpenCV 4.5.1版本:https://cfhcable.dl.sourceforge.net/project/opencvlibrary/4.5.1/opencv-4.5.1-android-sdk.zip

解压后本地目录为D:\Code\temp\opencv-4.5.1-android-sdk

将OpenCV-android-sdk\sdk\native\libs\arm64-v8a\libopencv_java4.so拷贝到app\libs\

将OpenCV-android-sdk\sdk\native\jni\include中的内容拷贝到app\src\main\cpp\include

集成GLM

GLM的集成就更简单了,源码都是hpp文件(即定义和实现在同一个文件中)。

下载GLM 0.9.9.8版本:https://github.com/g-truc/glm/archive/refs/tags/0.9.9.8.zip

解压后本地目录为D:\Code\temp\glm-0.9.9.8

将glm-0.9.9.8\glm中的内容拷贝到app\src\main\cpp\include

参考

Android: Use Assimp to load a 3D model:

AssimpAndroid: https://github.com/anandmuralidhar24/AssimpAndroid

使用Android Studio+CMakeLists编译assimp: https://blog.csdn.net/u010302327/article/details/104473671

TestAssimp: https://blog.csdn.net/u010302327/article/details/104473671

Assimp编译实录: https://blog.csdn.net/fyfcauc/article/details/72627996

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyyxsd.html