# Class ImageLabel

java.lang.Object
com.codename1.ai.vision.ImageLabel

public final class ImageLabel extends Object
Portable ranked image-classification label. Confidence is normalized to 0..1. The numeric index is a backend/model class index and should not be treated as stable across different backends; portable code should prefer the text label.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImageLabel(String text, float confidence, int index)`
  Creates a label without backend metadata.
  `ImageLabel(String text, float confidence, int index, VisionMetadata metadata)`
  Creates a label with backend diagnostics.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `float`
  `getConfidence()`
  `int`
  `getIndex()`
  Returns the backend/model class index when the selected classifier exposes one.
  `VisionMetadata`
  `getMetadata()`
  `String`
  `getText()`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ImageLabel

    public ImageLabel(String text, float confidence, int index)
    Creates a label without backend metadata.
    Parameters:
      `text` - normalized label text
      `confidence` - provider confidence, normally from zero to one
      `index` - provider label index, or a negative value when unavailable

  - ### ImageLabel

    public ImageLabel(String text, float confidence, int index, VisionMetadata metadata)
    Creates a label with backend diagnostics.
    Parameters:
      `text` - normalized label text
      `confidence` - provider confidence, normally from zero to one
      `index` - provider label index, or a negative value when unavailable
      `metadata` - backend details, or `null`

- ## Method Details

  - ### getText

    public String getText()
    Returns:
      human-readable class label

  - ### getConfidence

    public float getConfidence()
    Returns:
      classification confidence in the range 0..1

  - ### getIndex

    public int getIndex()
    Returns the backend/model class index when the selected classifier exposes one. The index identifies a class in that specific model; it is not portable across models or backends. Apple Vision does not expose a numeric class index and therefore returns `-1`. Prefer `getText()` when writing backend-independent application logic.
    Returns:
      backend/model class index, or `-1` when unavailable

  - ### getMetadata

    public VisionMetadata getMetadata()
    Returns:
      backend metadata, or `null` when manually constructed