SHARE
TWEET

Untitled

a guest May 16th, 2019 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top