ImageLabeling
Stay organized with collections
Save and categorize content based on your preferences.
Entry point to get an ImageLabeler
for finding ImageLabel
s in
a supplied image.
An image labeler is created via
getClient(ImageLabelerOptionsBase)
.
Example:
ImageLabeler imageLabeler = ImageLabeling.getClient(options);
To perform label 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 labels in the supplied InputImage
.
Task<List<ImageLabel>> task = imageLabeler.process(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
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()
|
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eImageLabeling\u003c/code\u003e is the entry point for image labeling tasks in ML Kit, providing access to an \u003ccode\u003eImageLabeler\u003c/code\u003e instance.\u003c/p\u003e\n"],["\u003cp\u003eYou create an \u003ccode\u003eImageLabeler\u003c/code\u003e using \u003ccode\u003eImageLabeling.getClient()\u003c/code\u003e with specified options.\u003c/p\u003e\n"],["\u003cp\u003eTo detect labels, you process an \u003ccode\u003eInputImage\u003c/code\u003e (created from a Bitmap, ByteBuffer, etc.) with the \u003ccode\u003eImageLabeler\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eRemember to call \u003ccode\u003eImageLabeler.close()\u003c/code\u003e when finished to release resources.\u003c/p\u003e\n"]]],[],null,["# ImageLabeling\n\npublic class **ImageLabeling** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nEntry point to get an [ImageLabeler](/android/reference/com/google/mlkit/vision/label/ImageLabeler)\nfor finding [ImageLabel](/android/reference/com/google/mlkit/vision/label/ImageLabel)s in\na supplied image.\n\nAn image labeler is created via [getClient(ImageLabelerOptionsBase)](/android/reference/com/google/mlkit/vision/label/ImageLabeling#getClient(com.google.mlkit.vision.label.ImageLabelerOptionsBase)).\n\nExample: \n\n ImageLabeler imageLabeler = ImageLabeling.getClient(options); \n\nTo perform label detection in an image, you first need to create an instance of\n[InputImage](/android/reference/com/google/mlkit/vision/common/InputImage)\nfrom a [Bitmap](//developer.android.com/reference/android/graphics/Bitmap.html),\n[ByteBuffer](//developer.android.com/reference/java/nio/ByteBuffer.html), etc. See\n[InputImage](/android/reference/com/google/mlkit/vision/common/InputImage)\ndocumentation for more details. For example, the code below creates an [InputImage](/android/reference/com/google/mlkit/vision/common/InputImage)\nfrom a [Bitmap](//developer.android.com/reference/android/graphics/Bitmap.html). \n\n InputImage image = InputImage.fromBitmap(bitmap, rotationDegrees); \n\nThen the code below can detect labels in the supplied [InputImage](/android/reference/com/google/mlkit/vision/common/InputImage). \n\n Task\u003cList\u003cImageLabel\u003e\u003e task = imageLabeler.process(image);\n task.addOnSuccessListener(...).addOnFailureListener(...); \n\n### Public Method Summary\n\n|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [ImageLabeler](/android/reference/com/google/mlkit/vision/label/ImageLabeler) | [getClient](/android/reference/com/google/mlkit/vision/label/ImageLabeling#getClient(com.google.mlkit.vision.label.ImageLabelerOptionsBase))([ImageLabelerOptionsBase](/android/reference/com/google/mlkit/vision/label/ImageLabelerOptionsBase) options) Gets an new instance of [ImageLabeler](/android/reference/com/google/mlkit/vision/label/ImageLabeler) that labels a supplied image. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public static [ImageLabeler](/android/reference/com/google/mlkit/vision/label/ImageLabeler)\n**getClient** ([ImageLabelerOptionsBase](/android/reference/com/google/mlkit/vision/label/ImageLabelerOptionsBase) options)\n\nGets an new instance of [ImageLabeler](/android/reference/com/google/mlkit/vision/label/ImageLabeler)\nthat labels a supplied image.\n\nTo release the resources associated with a [ImageLabeler](/android/reference/com/google/mlkit/vision/label/ImageLabeler),\nyou need to ensure that [ImageLabeler.close()](/android/reference/com/google/mlkit/vision/label/ImageLabeler#close())\nis called on the resulting [ImageLabeler](/android/reference/com/google/mlkit/vision/label/ImageLabeler)\ninstance once it will no longer be used. \n\n##### Parameters\n\n| options | the options for the image labeler. It should be one of the concrete options like [ImageLabelerOptions](/android/reference/com/google/mlkit/vision/label/defaults/ImageLabelerOptions) or [CustomImageLabelerOptions](/android/reference/com/google/mlkit/vision/label/custom/CustomImageLabelerOptions). |\n|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|"]]