Python Mediapipe PoseLandmarker.detect_async refuses to acknowledge timestamp_ms

1 day ago 1
ARTICLE AD BOX

The OP code that doesn't work differs a little from the guide you referred to.

Here is the signature you're calling into:

def detect_async( self, image: image_lib.Image, timestamp_ms: int, image_processing_options: Optional[_ImageProcessingOptions] = None, ) -> None:

Note that the first arg is self, which suggests you will need an object instance, something the OP code lacks.

This line makes SomeClass look like a_scalar, which is bad.

mp_pose = mp.tasks.vision.PoseLandmarker

I think you wanted this instead, so you create an instance of that class:

mp_pose = mp.tasks.vision.PoseLandmarker()

It would read a bit nicer if you pushed some of the verboseness into an import:

from mediapipe.tasks.vision import PoseLandmarker mp_pose = PoseLandmarker()

I have no idea why that guide's author chose to phrase things this way:

PoseLandmarker = mp.tasks.vision.PoseLandmarker PoseLandmarkerOptions = mp.tasks.vision.PoseLandmarkerOptions PoseLandmarkerResult = mp.tasks.vision.PoseLandmarkerResult

It would be much more pythonic to phrase those as "from mp.tasks.vision import FooBar". Hit it with isort and you'll wind up with a single import statement which creates three separate symbols.

Read Entire Article