From c485b7c01db12764fb8de40e990d25bf90ede045 Mon Sep 17 00:00:00 2001 From: Onuralp SEZER Date: Sun, 10 Dec 2023 19:19:12 +0300 Subject: [PATCH] =?UTF-8?q?feat(opencv):=20=E2=9C=A8opencv=20upgrade=20to?= =?UTF-8?q?=204.8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onuralp SEZER --- .gitignore | 11 +++-------- .idea/gradle.xml | 20 -------------------- .idea/kotlinc.xml | 6 ------ README.md | 8 ++++---- app/build.gradle | 7 ++++--- gradle.properties | 1 - patches/cv_build_gradle.patch | 11 +++++++---- settings.gradle | 4 ++-- setupOpenCV.sh | 11 ++++++----- 9 files changed, 26 insertions(+), 53 deletions(-) delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/kotlinc.xml diff --git a/.gitignore b/.gitignore index 4cbd563..0ce3b26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,7 @@ *.iml .gradle /local.properties -/.idea/.name -/.idea/deploymentTargetDropDown.xml -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml +/.idea .DS_Store /build /captures @@ -20,11 +13,13 @@ local.properties opencvsdk460/ opencvsdk470/ opencvsdk480/ +opencvsdk481/ OpenCV-android-sdk/ opencv-4.6.0-android-sdk.zip opencv-4.7.0-android-sdk.zip opencv-4.8.0-android-sdk.zip +opencv-4.8.1-android-sdk.zip OpenCV4Android.zip # Ignore zip files, because setupOpenCV.sh will download a zip file *.zip diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 81eb7e4..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index 1ee496d..0000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/README.md b/README.md index cec0603..03d451d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ MIT Kotlin Gradle - OpenCV + OpenCV Conventional Commits android-studio GithubCI @@ -23,7 +23,7 @@

-This android project is barebone setting up OpenCV 4.8.0 (and other 4.x.y versions) for Android in [Android Studio](https://developer.android.com/studio) with Native Development Kit (NDK) support. +This android project is barebone setting up OpenCV 4.8.1 (and other 4.x.y versions) for Android in [Android Studio](https://developer.android.com/studio) with Native Development Kit (NDK) support. [Android NDK](https://developer.android.com/ndk) enables you to implement your [OpenCV](https://opencv.org) image processing pipeline in C++ and call that C++ code from Android Kotlin/Java code through JNI ([Java Native Interface](https://en.wikipedia.org/wiki/Java_Native_Interface)). This sample Android application displays a live camera feed only and camera switch to back and front in runtime. @@ -40,8 +40,8 @@ This sample Android application displays a live camera feed only and camera swit * Paste this repository *Github URL*, choose a *project directory* and click next. 4. Install *OpenCV Android release* : - * Download [OpenCV 4.8.0 Android release](https://github.com/opencv/opencv/releases/download/4.8.0/opencv-4.8.0-android-sdk.zip) or download latest available Android release on [OpenCV website](https://opencv.org/releases/). - * Unzip downloaded file and put **OpenCV-android-sdk** directory next your project and rename folder `opencvsdk480`. If you want to place somewhere else please change path in `settings.gradle` + * Download [OpenCV 4.8.1 Android release](https://github.com/opencv/opencv/releases/download/4.8.1/opencv-4.8.1-android-sdk.zip) or download latest available Android release on [OpenCV website](https://opencv.org/releases/). + * Unzip downloaded file and put **OpenCV-android-sdk** directory next your project and rename folder `opencvsdk481`. If you want to place somewhere else please change path in `settings.gradle` * Optional(For linux) you can run setupOpenCV.sh for automatic download and setup gradle file for opencv diff --git a/app/build.gradle b/app/build.gradle index 1b7c429..2ed8b4d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,7 +24,7 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { - arguments "-DOpenCV_DIR=" + file('../opencvsdk480').absolutePath + "/sdk/native/jni", + arguments "-DOpenCV_DIR=" + file('../opencvsdk481').absolutePath + "/sdk/native/jni", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared" cppFlags '' @@ -56,6 +56,7 @@ android { } buildFeatures { viewBinding true + buildConfig true } @@ -76,8 +77,8 @@ dependencies { // Material implementation 'com.google.android.material:material:1.10.0' - //OpenCV - implementation project(path: ':opencvsdk480') + //OpenCV-4 + implementation project(path: ':opencvsdk481') //Timber Log implementation 'com.jakewharton.timber:timber:5.0.1' diff --git a/gradle.properties b/gradle.properties index 61cc25f..72ed97e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,5 +15,4 @@ android.nonTransitiveRClass=true kotlin.code.style=official org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1536M" -Dfile.encoding\=UTF-8 android.useAndroidX=true -android.defaults.buildfeatures.buildconfig=true android.nonFinalResIds=false diff --git a/patches/cv_build_gradle.patch b/patches/cv_build_gradle.patch index b4721a0..5edbff6 100644 --- a/patches/cv_build_gradle.patch +++ b/patches/cv_build_gradle.patch @@ -1,6 +1,8 @@ ---- build.gradle 2023-06-28 15:45:08.000000000 +0300 -+++ build.gradle.in 2023-09-03 13:00:51.845554298 +0300 -@@ -98,11 +98,12 @@ +diff --git a/opencvsdk481/sdk/build.gradle b/opencvsdk481/sdk/build.gradle +index 1ed73f5..ccafa93 100644 +--- a/opencvsdk481/sdk/build.gradle ++++ b/opencvsdk481/sdk/build.gradle +@@ -98,11 +98,12 @@ println "OpenCV: " +openCVersionName + " " + project.buildscript.sourceFile android { @@ -16,7 +18,7 @@ versionCode openCVersionCode versionName openCVersionName -@@ -116,11 +117,14 @@ +@@ -116,11 +117,15 @@ android { } compileOptions { @@ -28,6 +30,7 @@ + + buildFeatures { + aidl true ++ buildConfig true } - diff --git a/settings.gradle b/settings.gradle index 7a11a5e..1353f76 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,5 +14,5 @@ dependencyResolutionManagement { } rootProject.name = "cvCamera" include ':app' -include ':opencvsdk480' -project(":opencvsdk480").projectDir = file("opencvsdk480/sdk") +include ':opencvsdk481' +project(":opencvsdk481").projectDir = file("opencvsdk481/sdk") diff --git a/setupOpenCV.sh b/setupOpenCV.sh index aa3df42..8bfad8f 100755 --- a/setupOpenCV.sh +++ b/setupOpenCV.sh @@ -1,8 +1,9 @@ -#!/usr/bin/bash +#!/usr/bin/env sh -wget -O opencv-4.8.0-android-sdk.zip https://github.com/opencv/opencv/releases/download/4.8.0/opencv-4.8.0-android-sdk.zip -unzip -qq opencv-4.8.0-android-sdk.zip -mv OpenCV-android-sdk opencvsdk480 +wget -O opencv-4.8.1-android-sdk.zip https://github.com/opencv/opencv/releases/download/4.8.1/opencv-4.8.1-android-sdk.zip +unzip -qq opencv-4.8.1-android-sdk.zip +mv OpenCV-android-sdk opencvsdk481 # Apply OpenCV Build.gradle patch -sudo patch opencvsdk480/sdk/build.gradle patches/cv_build_gradle.patch +# Sudo because of Github action +sudo patch opencvsdk481/sdk/build.gradle patches/cv_build_gradle.patch