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 DetectedObject s 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

From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()

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 .

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年10月31日 UTC.