Skip to content

upgrade library & kotlin version & modify demo #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "com.google.android.material:material:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "androidx.appcompat:appcompat:1.3.1"
implementation "com.google.android.material:material:1.2.1"

// Camera
implementation "com.otaliastudios:cameraview:1.5.1"
implementation "com.otaliastudios:cameraview:1.6.1"

// Android face detector
implementation "com.github.husaynhakeem:android-face-detector:2.0" // Remote
// implementation(project(":facedetector")) // Local
// implementation "com.github.husaynhakeem:android-face-detector:2.0" // Remote
implementation(project(":facedetector")) // Local
}
13 changes: 13 additions & 0 deletions app/src/main/java/husaynhakeem/io/facedetectorapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package husaynhakeem.io.facedetectorapp

import android.os.Bundle
import android.util.Log
import android.util.Size
import androidx.appcompat.app.AppCompatActivity
import com.otaliastudios.cameraview.Facing
import husaynhakeem.io.facedetector.FaceBounds
import husaynhakeem.io.facedetector.FaceDetector
import husaynhakeem.io.facedetector.FaceDetector.OnFaceDetectionResultListener
import husaynhakeem.io.facedetector.Frame
import husaynhakeem.io.facedetector.LensFacing
import kotlinx.android.synthetic.main.activity_main.*
Expand Down Expand Up @@ -42,6 +45,16 @@ class MainActivity : AppCompatActivity() {

private fun setupCamera(lensFacing: Facing) {
val faceDetector = FaceDetector(faceBoundsOverlay)
faceDetector.setonFaceDetectionFailureListener(object : OnFaceDetectionResultListener {
override fun onSuccess(faceBounds: List<FaceBounds>) {
Log.e("MainActivity","Show faceBounds $faceBounds")
}

override fun onFailure(exception: Exception) {

}

})
viewfinder.facing = lensFacing
viewfinder.addFrameProcessor {
faceDetector.process(
Expand Down
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = "1.3.72"
ext{
agp_version = "4.2.1"
kotlin_version = "1.7.20"
// coroutine
coroutine_version = "1.6.3"
kotlin_coroutines_version = coroutine_version
}
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.2.1"
classpath "com.android.tools.build:gradle:$agp_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
76 changes: 72 additions & 4 deletions facedetector/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply from: 'https://raw.githubusercontent.com/CKS-ROC/Useful_Gradle/master/version.gradle'
def version = this.ext.default_version()
this.project.version = version.versionName

this.project.group = 'com.github.husaynhakeem'
this.description = this.project.name
this.archivesBaseName = 'android-face-detector'

ext {
// maven_properties_file = "properties_file path"
// maven_repo_name = 'XXXX'
// Sonatype_NexusUrl_Url="Nexus Url"+maven_repo_name

isToRemoteRepo =true
isToInternalRepo = true
isToMavenLocal = true
isToGit = false
isSonatype_Nexus = true

mavPublishToInternalRepo = true
mavRepoInternalUrl = "path/to/internal/repo"

//FIXME library POM please modify those
scmUrl = 'https://github.com/husaynhakeem/android-face-detector/tree/master/facedetector'
// project git
developerid = 'husaynhakeem'
developername = 'husaynhakeem'
developeremail = 'husaynhakeem'
scmConnectionUrl = 'https://www.linkedin.com/in/husaynhakeem'
scmDeveloperConnectionUrl = 'https://www.linkedin.com/in/husaynhakeem'

mavDevelopers = ["husaynhakeem": "@husaynahakeem"]
mavSiteUrl = "https://github.com/husaynhakeem/android-face-detector/tree/master/facedetector"
mavGitUrl = mavSiteUrl + '.git'
mavLibraryLicenses = ["Apache-2.0": 'http://www.apache.org/licenses/LICENSE-2.0.txt']
mavLibraryDescription = "facedetector"
}
android {
compileSdkVersion 30
defaultConfig {
Expand All @@ -22,8 +58,40 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "com.google.mlkit:face-detection:16.0.1"
implementation "com.google.android.gms:play-services-mlkit-face-detection:16.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// coroutine
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"

implementation "androidx.appcompat:appcompat:1.3.1"
implementation "com.google.mlkit:face-detection:16.1.5"
implementation "com.google.android.gms:play-services-mlkit-face-detection:16.1.5"
}

apply from: 'https://raw.githubusercontent.com/CMingTseng/Useful_Gradle/master/install.gradle'

task increaseVersion {
group "version Tasks"
doLast {
this.project.ext.increaseVersion("")
}
}

task increaseHotfixVersion {
group "version Tasks"
doLast {
this.project.ext.increaseHotfixVersion("")
}
}

task decreaseVersion {
group "version Tasks"
doLast {
this.project.ext.decreaseVersion("")
}
}

task showCurrentVersion {
group "version Tasks"
this.project.ext.currentVersion("")
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class FaceDetector(private val faceBoundsOverlay: FaceBoundsOverlay) {
// Correct the detected faces so that they're correctly rendered on the UI, then
// pass them to [faceBoundsOverlay] to be drawn.
val faceBounds = faces.map { face -> face.toFaceBounds(this) }
onFaceDetectionResultListener?.onSuccess(faceBounds)
mainExecutor.execute { faceBoundsOverlay.updateFaces(faceBounds) }
}
.addOnFailureListener { exception ->
Expand Down
1 change: 0 additions & 1 deletion facedetector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<resources>
<string name="app_name">FaceDetector</string>
</resources>
5 changes: 5 additions & 0 deletions facedetector/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Sat Oct 22 20:54:06 CST 2022
VERSION_NAME_HOTFIX=0
VERSION_NAME_BUILD=1
VERSION_CODE=11
VERSION_NAME_PREFIX=2.0
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
kotlin.code.style=official
# R8 Shrinker
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip