ObjectDetection

  • ObjectDetection is the entry point for getting an ObjectDetector to find DetectedObjects in an image.

  • An ObjectDetector is created using the getClient method with specified options.

  • To perform object detection, you first create an InputImage from a source like a Bitmap or ByteBuffer.

  • Object detection is performed by calling the process method on the ObjectDetector instance with the InputImage, which returns a Task.

  • Resources associated with an ObjectDetector should be released by calling its close() method when no longer needed.

public class ObjectDetection extends Object

Entry point to get an ObjectDetector for finding DetectedObjects in a supplied image.

An ObjectDetector is created via getClient(ObjectDetectorOptionsBase).

Example:

ObjectDetector objectDetector = ObjectDetection.getClient(options); 

To perform object detection in an image, you first need to create an instance of InputImage from a Bitmap, ByteBuffer, etc. See InputImage documentation for more details. For example, the code below creates an InputImage from a Bitmap.

InputImage image = InputImage.fromBitmap(bitmap, rotationDegrees); 

Then the code below can detect objects in the supplied InputImage.

Task<List<DetectedObject>> task = objectDetector.process(image);
 task.addOnSuccessListener(...).addOnFailureListener(...); 

Public Method Summary

static ObjectDetector
getClient(ObjectDetectorOptionsBase options)
Gets a new instance of ObjectDetector that can detect objects in a supplied image with the given options.

Inherited Method Summary

Public Methods

public static ObjectDetector getClient (ObjectDetectorOptionsBase options)

Gets a new instance of ObjectDetector that can detect objects in a supplied image with the given options.

To release the resources associated with an ObjectDetector, you need to ensure that ObjectDetector.close() is called on the resulting ObjectDetector instance once it will no longer be used.

Parameters
options the options for the object detector. It should be one of the concrete options like ObjectDetectorOptions or CustomObjectDetectorOptions.