shubham0204 / FaceRecognition_With_FaceNet_Android

Face Recognition using the FaceNet model and MLKit on Android.
https://towardsdatascience.com/using-facenet-for-on-device-face-recognition-with-android-f84e36e19761
Apache License 2.0
264 stars 88 forks source link

Thread Exception: Only the original thread that created a view hierarchy can touch its views #12

Closed SarfarazAliToori closed 3 years ago

SarfarazAliToori commented 3 years ago

Hi I am trying to run it on API 21, But inFrameAnalyser.kt line no 164 boundingBoxOverlay.invalidate() will through exception. Please help me I am a beginner Thanks in advance.

E/AndroidRuntime: FATAL EXCEPTION: Thread-3
Process: com.example.facerecognition, PID: 12921
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7809)
at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1338)
at android.view.ViewGroup.invalidateChild(ViewGroup.java:5446)
at android.view.View.invalidateInternal(View.java:14749)
at android.view.View.invalidate(View.java:14713)
at android.view.View.invalidate(View.java:14697)
at com.example.facerecognition.FrameAnalyser$analyze$1$1.run(FrameAnalyser.kt:150)
at java.lang.Thread.run(Thread.java:762)
shubham0204 commented 3 years ago

@SarfarazAliToori, please check if the issue is resolved in the latest commit.

SarfarazAliToori commented 3 years ago

@shubham0204 It does not work the project is going to crush. I don't know what's the problem.