Hello everyone I am building OpenCV for Android with opencv_conitrb. I am using the following cmake:
cmake -GNinja -DCMAKE_MAKE_PROGRAM=c:/ninja/ninja -DCMAKE_INSTALL_PREFIX=E:/OpenCVAndroidSdk -DANDROID_PROJECTS_BUILD_TYPE="ANT" -DBUILD_ANDROID_PROJECTS=ON -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_JAVA=ON -DBUILD_opencv_java=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_FAT_JAVA_LIB=ON -DBUILD_PYTHON=OFF -DINSTALL_ANDROID_EXAMPLES=OFF -DANDROID_EXAMPLES_WITH_LIBS=OFF -DBUILD_DOCS=OFF -DWITH_OPENCL=ON -DANDROID_NDK_HOST_X64=ON -DANDROID_NDK=C:/Users/volce/AppData/Local/Android/Sdk/ndk/android-ndk-r25b/ -DANDROID_SDK=C:/Users/volce/AppData/Local/Android/Sdk -DCMAKE_TOOLCHAIN_FILE=C:/Users/volce/AppData/Local/Android/Sdk/ndk/android-ndk-r25b/build/cmake/android.toolchain.cmake -DANDROID_TOOLCHAIN=clang -DANDROID_STL=c++_static -DANDROID_ARM_NEON=ON -DANDROID_ABI=arm64-v8a -DANDROID_ABI=x86_64 -DANDROID_ABI=x86 -DANDROID_ABI=arm64-v8a -DANDROID_NDK_HOST_X64=ON -D BUILD_opencv_python3=OFF -D BUILD_opencv_python2=OFF -D OPENCV_EXTRA_MODULES_PATH=E:/OpenCV/opencv_contrib-4.6.0/modules -DOPENCV_ENABLE_NONFREE=ON -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_SDK_TARGET=30 ..
But cmake can’t find java and ant:
-- OpenCV modules:
-- To be built: aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: alphamat cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java julia matlab ovis python2 python3 sfm ts viz
-- Applications: -
-- Documentation: NO
-- Non-free algorithms: YES
--
-- Android NDK: C:/Users/volce/AppData/Local/Android/Sdk/ndk/android-ndk-r25b (ver 25.1.8937393)
-- Android ABI: arm64-v8a
-- NDK toolchain: aarch64-linux-android-clang
-- STL type: c++_static
-- Native API level: 21
-- Android SDK: C:/Users/volce/AppData/Local/Android/Sdk (tools: 26.1.1 build tools: 33.0.0)
-- android tool: C:/Users/volce/AppData/Local/Android/Sdk/tools/android.bat
-- Projects build scripts: Ant/Eclipse compatible
--
-- GUI: NONE
--
-- Media I/O:
-- ZLib: z (ver 1.2.12)
-- JPEG: build-libjpeg-turbo (ver 2.1.2-62)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.2.0)
-- JPEG 2000: build (ver 2.4.0)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.19.1)
--
-- OpenCL: YES (no extra features)
-- Include path: E:/OpenCV/opencv-4.6.0/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python (for build): C:/Users/volce/AppData/Local/Programs/Python/Python32/python.exe
--
-- Java: export all functions
-- ant: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: E:/OpenCVAndroidSdk
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
I am using java 19. My environment variables:
JAVA_HOME: C:\Program Files\Java\jdk-18.0.1.1
ANT_HOME: C:\ant\bin
ANT_EXECUTABLE: C:\ant\bin\ant.bat
PATH:
- C:\Program Files\Java\jdk-18.0.1.1\bin
- C:\ant\bin