Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val options = FirebaseVisionObjectDetectorOptions.Builder()
- .setDetectorMode(FirebaseVisionObjectDetectorOptions.SINGLE_IMAGE_MODE)
- .enableMultipleObjects()
- .enableClassification()
- .build()
- val objectDetector = FirebaseVision.getInstance().getOnDeviceObjectDetector(options)
- val image = FirebaseVisionImage.fromBitmap(bitmap)
- objectDetector.processImage(image)
- .addOnSuccessListener { detectedObjects ->
- for (obj in detectedObjects) {
- val id = obj.trackingId // A number that identifies the object across images
- val bounds = obj.boundingBox // The object's position in the image
- // If classification was enabled:
- val category = obj.classificationCategory
- val confidence = obj.classificationConfidence
- val entityId = obj.entityId
- }
- }
- .addOnFailureListener { e ->
- // Task failed with an exception
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement