Advertisement
Guest User

Untitled

a guest
May 16th, 2019
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.98 KB | None | 0 0
  1. val options = FirebaseVisionObjectDetectorOptions.Builder()
  2.     .setDetectorMode(FirebaseVisionObjectDetectorOptions.SINGLE_IMAGE_MODE)
  3.     .enableMultipleObjects()
  4.     .enableClassification()
  5.     .build()
  6.  
  7.  val objectDetector = FirebaseVision.getInstance().getOnDeviceObjectDetector(options)
  8.  val image = FirebaseVisionImage.fromBitmap(bitmap)
  9.  
  10.  objectDetector.processImage(image)
  11.         .addOnSuccessListener { detectedObjects ->
  12.             for (obj in detectedObjects) {
  13.                 val id = obj.trackingId       // A number that identifies the object across images
  14.                 val bounds = obj.boundingBox  // The object's position in the image
  15.  
  16.                 // If classification was enabled:
  17.                 val category = obj.classificationCategory
  18.                 val confidence = obj.classificationConfidence
  19.                 val entityId = obj.entityId
  20.             }
  21.         }
  22.         .addOnFailureListener { e ->
  23.             // Task failed with an exception
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement