Skip to content

Commit

Permalink
Fixing Android application throwing an error of no value if no face i…
Browse files Browse the repository at this point in the history
…s detected in any frame. (#287)

* Fixing Android application throwing an error of no value if no face is detected in a video frame.

* Added tag string.

* Added the check to see if faceBlendshapes is Present for the frame and removed the generic try and catch block.

* Log info correction
  • Loading branch information
SanjanHegde authored Mar 25, 2024
1 parent 97c3a0c commit 1922205
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ class FaceBlendshapesResultAdapter :

fun updateResults(faceLandmarkerResult: FaceLandmarkerResult? = null) {
categories = MutableList(52) { null }
if (faceLandmarkerResult != null) {
val sortedCategories = faceLandmarkerResult.faceBlendshapes().get()[0].sortedBy { -it.score() }
if (faceLandmarkerResult != null && faceLandmarkerResult.faceBlendshapes().isPresent) {
val faceBlendshapes = faceLandmarkerResult.faceBlendshapes().get()
val sortedCategories = faceBlendshapes[0].sortedByDescending { it.score() }
val min = kotlin.math.min(sortedCategories.size, categories.size)
for (i in 0 until min) {
categories[i] = sortedCategories[i]
}
} else {
Log.v(
"FaceBlendshapesResultAdapter",
"FaceLandmarkerResult is null or faceBlendshapes has no value is present for this frame"
)
}
}

Expand Down

0 comments on commit 1922205

Please sign in to comment.