husaynhakeem / android-face-detector

A real-time face detection Android library
MIT License
479 stars 79 forks source link

how to listen if face is detected ? #14

Open monikkacha opened 3 years ago

monikkacha commented 3 years ago

i have implemented lib in my project and followed docs ,

i want to listen if face is detected , i know that there is a on faied result listenter , where i need to pass result listenere which gives me onSuccess and onFailed callback methods , but i am not getting any response , neither success nor failure . i even tried to impalement interface but results are same .

please let me know why does its happening , and thank you if you can help me

CMingTseng commented 2 years ago

Dear Sir

  1. open app build.gradle // implementation "com.github.husaynhakeem:android-face-detector:2.0" // Remote <---close implementation(project(":facedetector")) // Local <---opne

  2. modify FaceDetector.kt at line 94 & 95 https://github.com/husaynhakeem/android-face-detector/blob/a8162ac724d1a439b9e2040c33cd2a1e69ae657a/facedetector/src/main/java/husaynhakeem/io/facedetector/FaceDetector.kt#L94

add "onFaceDetectionResultListener?.onSuccess(faceBounds)"

  1. modify demo MainActivity.kt line 44 & 45

    https://github.com/husaynhakeem/android-face-detector/blob/a8162ac724d1a439b9e2040c33cd2a1e69ae657a/app/src/main/java/husaynhakeem/io/facedetectorapp/MainActivity.kt#L44

add

faceDetector.setonFaceDetectionFailureListener(object : FaceDetector.OnFaceDetectionResultListener { override fun onSuccess(faceBounds: List) { Log.e("YOOOOO","Get face $faceBounds ") } override fun onFailure(exception: Exception) {

        }
    })