public final class ImageLabel

  1. Object
  2. ImageLabel
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.

Constructors

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

Methods

public String getText()
public float getConfidence()
public int getIndex()Returns the backend/model class index when the selected classifier exposes one.
public VisionMetadata getMetadata()

Inherited methods

Constructor details

ImageLabel

public ImageLabel(String text, float confidence, int index)
Creates a label without backend metadata.

Parameters

text String
normalized label text
confidence float
provider confidence, normally from zero to one
index int
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 String
normalized label text
confidence float
provider confidence, normally from zero to one
index int
provider label index, or a negative value when unavailable
metadata VisionMetadata
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