Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ML Kit Introduction (for Android)

ML Kit Introduction (for Android)

Introduce the basic concept of ML Kit and how to use it in Android development

Elvis Lin

July 18, 2018
Tweet

More Decks by Elvis Lin

Other Decks in Programming

Transcript

  1. 關於我 • Elvis Lin • Android 與 iOS 永遠的初學者 •

    Twitter: @elvismetaphor • Blog: https://blog.elvismetaphor.me
  2. ML Kit • Cloud Vision API / Mobile Vision API

    • Tensorflow Lite • 整合 Firebase,託管「客製化的模型」
  3. ML Kit Base APIs • Image labeling • Text recognition

    (OCR) • Face detection • Barcode scanning • Landmark detection • others……
  4. 掃描 barcode (local) FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(image); FirebaseVisionBarcodeDetectorOptions options =

    new FirebaseVisionBarcodeDetectorOptions.Builder() .setBarcodeFormats( FirebaseVisionBarcode.FORMAT_QR_CODE, FirebaseVisionBarcode.FORMAT_AZTEC ) .build(); FirebaseVisionBarcodeDetector detector = FirebaseVision.getInstance() .getVisionBarcodeDetector(options); detector.detectInImage(image) .addOnSuccessListener(
 new OnSuccessListener<List<FirebaseVisionBarcode>>() { @Override public void onSuccess(List<FirebaseVisionBarcode> barcodes) {} }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) {} });
  5. 初始化 Detector FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(image);
 FirebaseVisionBarcodeDetectorOptions options = new

    FirebaseVisionBarcodeDetectorOptions.Builder() .setBarcodeFormats( FirebaseVisionBarcode.FORMAT_QR_CODE, FirebaseVisionBarcode.FORMAT_AZTEC ) .build(); FirebaseVisionBarcodeDetector detector = 
 FirebaseVision
 .getInstance() .getVisionBarcodeDetector(options);
  6. 取得結果 detector.detectInImage(image) .addOnSuccessListener(
 new OnSuccessListener<List<FirebaseVisionBarcode>>() { @Override public void onSuccess(List<FirebaseVisionBarcode>

    barcodes) {} }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) {} });
  7. ⽀支援的 barcode 格式 • Code 128 (FORMAT_CODE_128) • Code 39

    (FORMAT_CODE_39) • Code 93 (FORMAT_CODE_93) • Codabar (FORMAT_CODABAR) • EAN-13 (FORMAT_EAN_13) • EAN-8 (FORMAT_EAN_8) • ITF (FORMAT_ITF) • UPC-A (FORMAT_UPC_A) • UPC-E (FORMAT_UPC_E) •QR Code (FORMAT_QR_CODE) • PDF417 (FORMAT_PDF417) • Aztec (FORMAT_AZTEC) • Data Matrix (FORMAT_DATA_MATRIX)
  8. 辨識⽂文字 (local) FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(selectedImage); FirebaseVisionTextDetector detector = FirebaseVision.getInstance().getVisionTextDetector();

    detector.detectInImage(image) .addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() { @Override public void onSuccess(FirebaseVisionText text) {} }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) {} });
  9. 辨識⽂文字 (cloud) FirebaseVisionCloudDetectorOptions options = new FirebaseVisionCloudDetectorOptions.Builder() .setModelType(FirebaseVisionCloudDetectorOptions.LATEST_MODEL) .setMaxResults(15) .build();

    FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(selectedImage); FirebaseVisionCloudDocumentTextDetector detector = FirebaseVision.getInstance() .getVisionCloudDocumentTextDetector(options); detector.detectInImage(image) .addOnSuccessListener(new OnSuccessListener<FirebaseVisionCloudText>() { @Override public void onSuccess(FirebaseVisionCloudText text) {} }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) {} });
  10. 補充資料 • ML Kit 簡介 (for Android)
 https://blog.elvismetaphor.me/ml-kit-fundamentals-for- android-6444e2db0fdb •

    ML Kit 簡介 (for iOS)
 https://blog.elvismetaphor.me/ml-kit-fundamentals-for- ios-cb705044e69b