Performs pose landmarks detection on images.
This API expects a pre-trained pose landmarks model asset bundle. See
MPImage
PoseLandmarkerResult
Nested Classes
class | PoseLandmarker.PoseLandmarkerOptions | Options for setting up an PoseLandmarker . |
Fields
public static final Set<Connection> | POSE_LANDMARKS |
Public Methods
static PoseLandmarker |
createFromBuffer(Context context, ByteBuffer modelBuffer)
Creates a
PoseLandmarker instance from a model buffer and the default PoseLandmarker.PoseLandmarkerOptions . |
static PoseLandmarker |
createFromFile(Context context, String modelPath)
Creates a
PoseLandmarker instance from a model file and the default PoseLandmarker.PoseLandmarkerOptions . |
static PoseLandmarker |
createFromFile(Context context, File modelFile)
Creates a
PoseLandmarker instance from a model file and the default PoseLandmarker.PoseLandmarkerOptions . |
static PoseLandmarker |
createFromOptions(Context context, PoseLandmarker.PoseLandmarkerOptions landmarkerOptions)
Creates a
PoseLandmarker instance from a PoseLandmarker.PoseLandmarkerOptions . |
PoseLandmarkerResult | |
PoseLandmarkerResult |
detect(MPImage image, ImageProcessingOptions imageProcessingOptions)
Performs pose landmarks detection on the provided single image.
|
void |
detectAsync(MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Sends live image data to perform pose landmarks detection, and the results will be available
via the
OutputHandler.ResultListener provided in the PoseLandmarker.PoseLandmarkerOptions . |
void |
detectAsync(MPImage image, long timestampMs)
Sends live image data to perform pose landmarks detection with default image processing
options, i.e.
|
PoseLandmarkerResult |
detectForVideo(MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Performs pose landmarks detection on the provided video frame.
|
PoseLandmarkerResult |
detectForVideo(MPImage image, long timestampMs)
Performs pose landmarks detection on the provided video frame with default image processing
options, i.e.
|
Inherited Methods
Fields
Public Methods
public static PoseLandmarker createFromBuffer (Context context, ByteBuffer modelBuffer)
Creates a PoseLandmarker
instance from a model buffer and the default PoseLandmarker.PoseLandmarkerOptions
.
Parameters
context | an Android ERROR(/Context) . |
---|---|
modelBuffer | a direct ByteBuffer or a ERROR(/MappedByteBuffer) of the detection
model. |
Throws
if there is an error during PoseLandmarker creation.
|
public static PoseLandmarker createFromFile (Context context, String modelPath)
Creates a PoseLandmarker
instance from a model file and the default PoseLandmarker.PoseLandmarkerOptions
.
Parameters
context | an Android ERROR(/Context) . |
---|---|
modelPath | path to the pose landmarks model with metadata in the assets. |
Throws
if there is an error during PoseLandmarker creation.
|
public static PoseLandmarker createFromFile (Context context, File modelFile)
Creates a PoseLandmarker
instance from a model file and the default PoseLandmarker.PoseLandmarkerOptions
.
Parameters
context | an Android ERROR(/Context) . |
---|---|
modelFile | the pose landmarks model File instance. |
Throws
IOException | if an I/O error occurs when opening the tflite model file. |
---|---|
if there is an error during PoseLandmarker creation.
|
public static PoseLandmarker createFromOptions (Context context, PoseLandmarker.PoseLandmarkerOptions landmarkerOptions)
Creates a PoseLandmarker
instance from a PoseLandmarker.PoseLandmarkerOptions
.
Parameters
context | an Android ERROR(/Context) . |
---|---|
landmarkerOptions | a PoseLandmarker.PoseLandmarkerOptions instance. |
Throws
if there is an error during PoseLandmarker creation.
|
public PoseLandmarkerResult detect (MPImage image)
Performs pose landmarks detection on the provided single image with default image processing
options, i.e. without any rotation applied. Only use this method when the PoseLandmarker
is created with ERROR(/RunningMode.IMAGE)
. TODO update java doc
for input image format.
PoseLandmarker
supports the following color space types:
Parameters
image | a MediaPipe MPImage object for processing. |
---|
Throws
if there is an internal error. |
public PoseLandmarkerResult detect (MPImage image, ImageProcessingOptions imageProcessingOptions)
Performs pose landmarks detection on the provided single image. Only use this method when the
PoseLandmarker
is created with ERROR(/RunningMode.IMAGE)
. TODO update java
doc for input image format.
PoseLandmarker
supports the following color space types:
Parameters
image | a MediaPipe MPImage object for processing. |
---|---|
imageProcessingOptions | the ImageProcessingOptions specifying how to process the
input image before running inference. Note that region-of-interest is not supported
by this task: specifying ImageProcessingOptions.regionOfInterest() will result in
this method throwing an IllegalArgumentException. |
Throws
IllegalArgumentException | if the ImageProcessingOptions specify a
region-of-interest. |
---|---|
if there is an internal error. |
public void detectAsync (MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Sends live image data to perform pose landmarks detection, and the results will be available
via the OutputHandler.ResultListener
provided in the PoseLandmarker.PoseLandmarkerOptions
. Only use this
method when the PoseLandmarker
is created with ERROR(/RunningMode.LIVE_STREAM)
.
It's required to provide a timestamp (in milliseconds) to indicate when the input image is sent to the pose landmarker. The input timestamps must be monotonically increasing.
PoseLandmarker
supports the following color space types:
Parameters
image | a MediaPipe MPImage object for processing. |
---|---|
imageProcessingOptions | the ImageProcessingOptions specifying how to process the
input image before running inference. Note that region-of-interest is not supported
by this task: specifying ImageProcessingOptions.regionOfInterest() will result in
this method throwing an IllegalArgumentException. |
timestampMs | the input timestamp (in milliseconds). |
Throws
IllegalArgumentException | if the ImageProcessingOptions specify a
region-of-interest. |
---|---|
if there is an internal error. |
public void detectAsync (MPImage image, long timestampMs)
Sends live image data to perform pose landmarks detection with default image processing
options, i.e. without any rotation applied, and the results will be available via the OutputHandler.ResultListener
provided in the PoseLandmarker.PoseLandmarkerOptions
. Only use this method when the
PoseLandmarker
is created with ERROR(/RunningMode.LIVE_STREAM)
.
It's required to provide a timestamp (in milliseconds) to indicate when the input image is sent to the pose landmarker. The input timestamps must be monotonically increasing.
PoseLandmarker
supports the following color space types:
Parameters
image | a MediaPipe MPImage object for processing. |
---|---|
timestampMs | the input timestamp (in milliseconds). |
Throws
if there is an internal error. |
public PoseLandmarkerResult detectForVideo (MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Performs pose landmarks detection on the provided video frame. Only use this method when the
PoseLandmarker
is created with ERROR(/RunningMode.VIDEO)
.
It's required to provide the video frame's timestamp (in milliseconds). The input timestamps must be monotonically increasing.
PoseLandmarker
supports the following color space types:
Parameters
image | a MediaPipe MPImage object for processing. |
---|---|
imageProcessingOptions | the ImageProcessingOptions specifying how to process the
input image before running inference. Note that region-of-interest is not supported
by this task: specifying ImageProcessingOptions.regionOfInterest() will result in
this method throwing an IllegalArgumentException. |
timestampMs | the input timestamp (in milliseconds). |
Throws
IllegalArgumentException | if the ImageProcessingOptions specify a
region-of-interest. |
---|---|
if there is an internal error. |
public PoseLandmarkerResult detectForVideo (MPImage image, long timestampMs)
Performs pose landmarks detection on the provided video frame with default image processing
options, i.e. without any rotation applied. Only use this method when the PoseLandmarker
is created with ERROR(/RunningMode.VIDEO)
.
It's required to provide the video frame's timestamp (in milliseconds). The input timestamps must be monotonically increasing.
PoseLandmarker
supports the following color space types:
Parameters
image | a MediaPipe MPImage object for processing. |
---|---|
timestampMs | the input timestamp (in milliseconds). |
Throws
if there is an internal error. |