Skip to content

Commit

Permalink
Merge pull request #83 from onuralpszr/opencv481
Browse files Browse the repository at this point in the history
feat(opencv): ✨opencv version upgrade to 4.8.1
  • Loading branch information
onuralpszr authored Dec 10, 2023
2 parents 2de2882 + c485b7c commit 7c64cce
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 53 deletions.
11 changes: 3 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
20 changes: 0 additions & 20 deletions .idea/gradle.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/kotlinc.xml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a href="https://opensource.org/license/mit/"><img alt="MIT" src="https://img.shields.io/badge/License-MIT-yellow?logo=MIT&logoColor=white"></a>
<a href="https://kotlinlang.org/"><img alt="Kotlin" src="https://img.shields.io/badge/Kotlin-1.8.22-%23E34F26?logo=Kotlin&logoColor=white"></a>
<a href="https://gradle.org/releases/"><img alt="Gradle" src="https://img.shields.io/badge/Gradle-8.1.1-02303A?logo=Gradle&logoColor=white"></a>
<a href="https://opencv.org/"><img alt="OpenCV" src="https://img.shields.io/badge/OpenCV-4.8.0-5C3EE8?logo=OpenCV&logoColor=white"></a>
<a href="https://opencv.org/"><img alt="OpenCV" src="https://img.shields.io/badge/OpenCV-4.8.1-5C3EE8?logo=OpenCV&logoColor=white"></a>
<a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commit-1.0.0-FE5196?logo=conventionalcommits&logoColor=white"></a>
<a href="https://developer.android.com/studio"><img alt="android-studio" src="https://img.shields.io/badge/android studio-Giraffe-3DDC84?logo=androidstudio&logoColor=white"></a>
<a href="https://github.com/onuralpszr/CvCamera-Mobile/actions/workflows/android-ci.yml"><img alt="GithubCI" src="https://github.com/onuralpszr/CvCamera-Mobile/actions/workflows/android-ci.yml/badge.svg?branch=main"></a>
Expand All @@ -23,7 +23,7 @@
</p>


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.
Expand All @@ -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

Expand Down
7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down Expand Up @@ -56,6 +56,7 @@ android {
}
buildFeatures {
viewBinding true
buildConfig true
}


Expand All @@ -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'
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 7 additions & 4 deletions patches/cv_build_gradle.patch
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -16,7 +18,7 @@

versionCode openCVersionCode
versionName openCVersionName
@@ -116,11 +117,14 @@
@@ -116,11 +117,15 @@ android {
}

compileOptions {
Expand All @@ -28,6 +30,7 @@
+
+ buildFeatures {
+ aidl true
+ buildConfig true
}

-
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
11 changes: 6 additions & 5 deletions setupOpenCV.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7c64cce

Please sign in to comment.