Last active
July 10, 2018 13:40
-
-
Save qichuan/f907e42db0798bc9a1e6b0b7bf3b4000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Draw cigarette at the left mouth | |
*/ | |
private fun drawCigarette(canvas: Canvas, face: FirebaseVisionFace) { | |
val rightMouth = face.getLandmark(FirebaseVisionFaceLandmark.RIGHT_MOUTH) | |
val leftMouth = face.getLandmark(FirebaseVisionFaceLandmark.LEFT_MOUTH) | |
if (leftMouth != null && rightMouth != null) { | |
val mouthLength = ((leftMouth.position.x - rightMouth.position.x) * widthScaleFactor).toInt() | |
val cigaretteRect = Rect( | |
translateX(leftMouth.position.x).toInt() - mouthLength, | |
translateY(leftMouth.position.y).toInt(), | |
translateX(leftMouth.position.x).toInt(), | |
translateY(leftMouth.position.y).toInt() + mouthLength | |
) | |
canvas.drawBitmap(cigaretteBitmap, null, cigaretteRect, null) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment