APP ▸ Setup our playground. ▸ Build a simple camera app, take a photo and display the photo to the user. ▸ Add the special sauce ▸ Use Firebase ML Vision Kit to draw a simple box around all faces in the photo. ▸ Get creative ▸ Add a funny overlay, alter the image, do something fun! ▸ Get all SnapChatty. ▸ Do all of the above, except in realtime.
for real time. eg. contours and ANYTHING ELSE! ▸ Some features work but for one face only (again contours). ▸ … library is still in Beta, so the API can have breaking changes.
from Firebase? ▸ Contours? Landmarks? Classification? Speed or Accuracy? ▸ Different detectors for different data. interface FaceDetector { fun process(bitmap: Bitmap, callback: (Bitmap) -> Unit) }
draw on the photo? Boxes? Dots? Funny sunglasses? ▸ Separate the drawing from the detection ▸ Original photo + information about the faces detected => New photo interface Graphic { fun draw(bitmap: Bitmap, faces: List<FirebaseVisionFace>): Bitmap }
around all the faces in the image. ▸ Configure the Firebase options in you detector: private val options = FirebaseVisionFaceDetectorOptions.Builder() .setPerformanceMode(FirebaseVisionFaceDetectorOptions.FAST) .build() private val detector: FirebaseVisionFaceDetector = FirebaseVision.getInstance().getVisionFaceDetector(options)
draw a box around all the faces in the image. ▸ Draw boxes around each face detected override fun draw(bitmap: Bitmap, faces: List<FirebaseVisionFace>): Bitmap { val canvas = Canvas(bitmap) faces.forEach { face -> canvas.drawRect(face.boundingBox, whitePaint) } return bitmap }