Detector for finding FirebaseVisionObjects
in a supplied image.
A object detector is created via
getOnDeviceObjectDetector(FirebaseVisionObjectDetectorOptions) or
getOnDeviceObjectDetector(), if you wish to use the default options. For example,
the code below creates an object detector with default options.
FirebaseVisionObjectDetector objectDetector =
FirebaseVision.getInstance().getOnDeviceObjectDetector();
To perform object detection in an image, you first need to create an instance of
FirebaseVisionImage
from a Bitmap,
ByteBuffer, etc. See
FirebaseVisionImage
documentation for more details. For example, the code below creates a FirebaseVisionImage
from a ByteBuffer.
FirebaseVisionImage image
= FirebaseVisionImage.fromByteBuffer(byteBuffer, imageMetadata);
Then the code below can detect objects in the supplied FirebaseVisionImage.
Task<List<FirebaseVisionObject>> task = objectDetector.processImage(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
| void |
close()
|
| Task<List<FirebaseVisionObject>> |
| IOException |
|---|
Detects objects from supplied image.
For best efficiency, create a
FirebaseVisionImage object using following way:
fromByteBuffer(ByteBuffer, FirebaseVisionImageMetadata) if you need to
pre-process the image. E.g. allocate a direct ByteBuffer
and write processed pixels into the ByteBuffer.
FirebaseVisionImage factory methods will work as well, but possibly slightly
slower.
Note that the width and height of the provided image cannot be less than 32.
Task
that asynchronously returns a List of detected
FirebaseVisionObjects.