This class is deprecated.
The standalone ML Kit SDK replaces this API. For more information, refer to the migration guide.
Detector for finding FirebaseVisionObject
s
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(...);
Public Method Summary
void |
close()
|
Task<List<FirebaseVisionObject>> |
Inherited Method Summary
Public Methods
public void close ()
Throws
IOException |
---|
public Task<List<FirebaseVisionObject>> processImage (FirebaseVisionImage image)
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 directByteBuffer
and write processed pixels into theByteBuffer
.
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.
Returns
- A
Task
that asynchronously returns aList
of detectedFirebaseVisionObject
s.