Detection

public abstract class Detection


Represents one detected object in the results of com.google.mediapipe.tasks.version.objectdetector.ObjectDetector.

Summary

Public constructors

Public methods

abstract RectF

A RectF object to represent the bounding box of the detected object.

abstract List<Category>

A list of Category objects.

static Detection
create(List<Category> categories, RectF boundingBox)

Creates a Detection instance from a list of Category and a bounding box.

static Detection
create(
    List<Category> categories,
    RectF boundingBox,
    Optional<List<NormalizedKeypoint>> keypoints
)

Creates a Detection instance from a list of Category and a bounding box.

static Detection
createFromProto(DetectionProto.Detection detectionProto)

Creates a Detection instance from a com.google.mediapipe.formats.proto.DetectionProto.Detection protobuf message.

abstract Optional<List<NormalizedKeypoint>>

An optional list of NormalizedKeypoint associated with the detection.

Public constructors

Detection

public Detection()

Public methods

boundingBox

public abstract RectF boundingBox()

A RectF object to represent the bounding box of the detected object.

categories

public abstract List<Category> categories()

A list of Category objects.

create

public static Detection create(List<Category> categories, RectF boundingBox)

Creates a Detection instance from a list of Category and a bounding box.

Parameters
List<Category> categories

a list of Category objects that contain category name, display name, score, and the label index.

RectF boundingBox

a RectF object to represent the bounding box.

create

public static Detection create(
    List<Category> categories,
    RectF boundingBox,
    Optional<List<NormalizedKeypoint>> keypoints
)

Creates a Detection instance from a list of Category and a bounding box.

Parameters
List<Category> categories

a list of Category objects that contain category name, display name, score, and the label index.

RectF boundingBox

a RectF object to represent the bounding box.

Optional<List<NormalizedKeypoint>> keypoints

an optional list of NormalizedKeypoints associated with the detection.

createFromProto

public static Detection createFromProto(DetectionProto.Detection detectionProto)

Creates a Detection instance from a com.google.mediapipe.formats.proto.DetectionProto.Detection protobuf message.

Parameters
DetectionProto.Detection detectionProto

a com.google.mediapipe.formats.proto.DetectionProto.Detection protobuf message.

keypoints

public abstract Optional<List<NormalizedKeypoint>> keypoints()

An optional list of NormalizedKeypoint associated with the detection. Keypoints represent interesting points related to the detection. For example, the keypoints represent the eyes, ear and mouth from face detection model. Or in the template matching detection, e.g. KNIFT, they can represent the feature points for template matching.