hailo-poseTo close the application, press Ctrl+C.
This example demonstrates human pose estimation using the yolov8s_pose model for Hailo-8l (13 TOPS) and the yolov8m_pose model for Hailo-8 (26 TOPS).
hailo-pose --input rpiThere are 2 ways:
Specify the argument --input to usb:
hailo-pose --input usbThis will automatically detect the available USB camera (if multiple are connected, it will use the first detected).
Second way:
Detect the available camera using this script:
get-usb-cameraRun example using USB camera input - Use the device found by the previous script:
hailo-pose --input /dev/video<X>For additional options, execute:
hailo-pose --helpFor examples:
python pose_estimation.py --input usbEach person is represented as a HAILO_DETECTION with 17 keypoints (HAILO_LANDMARKS objects).
The get_keypoints function provides a dictionary mapping keypoint names to their corresponding indices. This dictionary includes keypoints for the nose, eyes, ears, shoulders, elbows, wrists, hips, knees, and ankles.
The basic idea is to utilize the pipeline's callback function. In simple terms, it can be thought of as a Python function that is invoked at the end of the pipeline when frame processing is complete.
This is the recommended location to implement your logic.
The callback function retrieves pose estimation metadata from the network output. The function parses the landmarks to extract the left and right eye coordinates, printing them to the terminal. If the --use-frame flag is set, the eyes are drawn on the user frame. Obtain the keypoints dictionary using the get_keypoints function.
-
Retrieve the Buffer:
- Extracts the
GstBufferfrom the probe info (info.get_buffer()). - If the buffer is invalid (
None), the function exits early.
- Extracts the
-
Frame Counting:
- Frame counting is handled automatically by the framework wrapper before the callback is invoked.
- The current frame count is retrieved using
user_data.get_count()for debugging purposes.
-
Extract Video Frame Properties:
- Retrieves the video format, width, and height from the pad using
get_caps_from_pad(pad).
- Retrieves the video format, width, and height from the pad using
-
Extract Video Frame:
- If
user_data.use_frameisTrue, the function extracts the video frame as a NumPy array usingget_numpy_from_buffer(buffer, format, width, height).
- If
-
Object Detection:
- Retrieves the Region of Interest (ROI) from the buffer using
hailo.get_roi_from_buffer(buffer). - Extracts detections from the ROI using
roi.get_objects_typed(hailo.HAILO_DETECTION).
- Retrieves the Region of Interest (ROI) from the buffer using
-
Parse Detections:
- For each detection:
- Extracts the label, bounding box, and confidence score.
- If the label is
"person", retrieves the track ID for the detected object. - Appends detection information (ID, label, confidence) to the debug string.
- For each detection:
-
Pose Estimation Landmarks:
- If landmarks are available for the detection:
- Retrieves the pose estimation landmarks (
hailo.HAILO_LANDMARKS). - Extracts specific keypoints (e.g.,
left_eye,right_eye) usingget_keypoints(). - Calculates the coordinates of the keypoints based on the bounding box and frame dimensions.
- Appends keypoint information (e.g., eye positions) to the debug string.
- If
user_data.use_frameisTrue, overlays visual markers (e.g., circles) on the video frame using OpenCV (cv2.circle()).
- Retrieves the pose estimation landmarks (
- If landmarks are available for the detection:
