models.pose_detection package¶
Submodules¶
models.pose_detection.camera module¶
Camera utilities for posture detection
- models.pose_detection.camera.is_camera_aligned(pose_landmark_result: PoseLandmarkerResult) bool ¶
Returns whether the camera is aligned to capture the person’s side view.
models.pose_detection.classification module¶
Posture classification
- models.pose_detection.classification.posture_angle(p1: Landmark, p2: Landmark) float64 ¶
Returns the angle (in degrees) between P2 and P3, where P3 is a point on the vertical axis of P1 (i.e. its x coordinate is the same as P1’s), and is the “ideal” location of the P2 landmark for good posture.
The y coordinate of P3 is irrelevant but for simplicity we set it to zero.
For a neck inclination calculation, take P1 to be the shoulder location and pivot point, and P2 to be the ear location.
For a torso inclination calculation, take P1 to be the hip location and pivot point, and P2 to be the hip location.
- models.pose_detection.classification.posture_classify(pose_landmark_result: PoseLandmarkerResult) bool ¶
Returns whether the pose in the image has good (True) or bad (False) posture.
Note: The camera should be aligned to capture the person’s side view; the output may not be accurate otherwise. See is_camera_aligned().
REF: https://learnopencv.com/building-a-body-posture-analysis-system-using-mediapipe
models.pose_detection.landmarking module¶
Pose landmarking
- class models.pose_detection.landmarking.AnnotatedImage(data: ndarray | None = None)¶
Bases:
object
Represents mutable annoted image through data attribute. Can be used to set annotated image within a callback asynchronously without raising an error.
- data: ndarray | None = None¶
- models.pose_detection.landmarking.display_landmarking(result: ~mediapipe.tasks.python.vision.pose_landmarker.PoseLandmarkerResult, output_image: ~mediapipe.python._framework_bindings.image.Image, timestamp: int, annotated_image=<class 'models.pose_detection.landmarking.AnnotatedImage'>) None ¶
Mutates annotated image to contain visualization of detected landmarks. Also prints debugging info to the standard output.
- Parameters:
result (PoseLandmarkerResult) – Landmarker result as returned by a mediapipe.tasks.vision.PoseLandmarker
output_image (mp.Image) – Raw image used for landmarking.
timestamp (int) – Video timestamp in milliseconds.
annotated_image (AnnotatedImage) – Image to mutate.
- models.pose_detection.landmarking.draw_landmarks_on_image(bgr_image: ndarray, detection_result: PoseLandmarkerResult) ndarray ¶
- Parameters:
bgr_image (np.ndarray) – CxWxH image array where channels are sorted in BGR.
detection_result (PoseLandmarkerResult) – Landmarker result as returned by a mediapipe.tasks.vision.PoseLandmarker
- Returns:
Image with landmarks annotated.
- Return type:
(np.ndarray)
models.pose_detection.routines module¶
Module contents¶
Pose detection module