1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #24473 from alexlyulkov:al/samples_with_maven

Updated Android samples for modern Android studio. Added OpenCV from Maven support. #24473

Updated samples for recent Android studio:

- added namespace field that is required in build.gradle files
- replaced _switch_ by _if-else_ because it doesn't work with constants from resources
- added missed log library dependency in face-detection/jni/CMakeLists.txt
- use local.properties to define NDK location

Added support for OpenCV from Maven. Now you can choose 3 possible sources of OpenCV lib in settings.gradle: SDK path, local Maven repository, public Maven repository. (Creating Maven repository from SDK is added here #24456 )

There are differences in project configs for SDK and Maven versions:

- different dependencies in build.gradle
- different OpenCV library names in CMakeLists.txt
- SDK version requires OpenCV_DIR definition

Requires:
- https://github.com/opencv/ci-gha-workflow/pull/124
- https://github.com/opencv-infrastructure/opencv-gha-dockerfile/pull/26
This commit is contained in:
alexlyulkov
2023-11-17 18:17:17 +07:00
committed by GitHub
parent fad0dbb9ac
commit 6c57ce9e09
17 changed files with 163 additions and 34 deletions
@@ -3,7 +3,12 @@ cmake_minimum_required(VERSION 3.6)
set(target mixed_sample)
project(${target} CXX)
set(ANDROID_OPENCV_COMPONENTS "opencv_java" CACHE STRING "")
if (OPENCV_FROM_SDK)
set(ANDROID_OPENCV_COMPONENTS "opencv_java" CACHE STRING "")
else()
set(ANDROID_OPENCV_COMPONENTS "OpenCV::opencv_java${OPENCV_VERSION_MAJOR}" CACHE STRING "")
endif()
message(STATUS "ANDROID_ABI=${ANDROID_ABI}")
find_package(OpenCV REQUIRED COMPONENTS ${ANDROID_OPENCV_COMPONENTS})