Skip to content

Latest commit

 

History

History
143 lines (118 loc) · 6.33 KB

File metadata and controls

143 lines (118 loc) · 6.33 KB

Pose Estimation

This example demonstrates pose estimation using the HailoRT C++ API. It supports Hailo-8, Hailo-8l and Hailo-10H devices. The application receives a HEF and images/video/camera as input, and returns the image/video with detection boxes, keypoints, and joints connections overlaid.

output example

Requirements

  • HailoRT
    • For Hailo-8: HailoRT==4.23.0
    • For Hailo-10: HailoRT==5.3.0

Supported Models

  • yolov8s_pose
  • yolov8m_pose

Usage

  1. Make sure you have installed all of the requirements.

  2. Clone the repository:

    git clone https://github.com/hailo-ai/hailo-apps.git
    cd hailo-apps/hailo_apps/cpp/pose_estimation
  3. Compile the project on the development machine

    • Linux
      ./build.sh
    • Windows
      cmake -S. -Bbuild -DCMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS=True
      cmake --build build --config Release

    This creates the directory hierarchy build/Release and compile an executable file called pose_estimation

  4. Run the example:

    ./build/x86_64/pose_estimation --net <hef_path> --input <image_or_video_or_camera_path>

Arguments

  • -n, --net:
    • A model name (e.g., yolov8n) → the script will automatically download and resolve the correct HEF for your device.
    • A file path to a local HEF → the script will use the specified network directly.
  • -i, --input:
    • An input source such as an image (bus.jpg), a video (video.mp4), a directory of images, or usb to use the system camera.
      • On Raspberry Pi, you can also use rpi to enable the Raspberry Pi camera.
    • A predefined input name from inputs.json (e.g., bus, street).
      • If you choose a predefined name, the input will be automatically downloaded if it doesn't already exist.
  • -b, --batch-size: [optional] Number of images in one batch. Defaults to 1.
  • -s, --save_stream_output: [optional] Save the output of the inference from a stream.
  • -o, --output-dir: [optional] Directory where output images/videos will be saved.
  • --camera-resolution: [optional][Camera only] Input resolution: sd (640x480), hd (1280x720), or fhd (1920x1080).
  • --output-resolution: [optional] Set output size using sd|hd|fhd, or pass custom width/height (e.g., --output-resolution 1920 1080).
  • -f, --framerate: [optional][Camera only] Override the camera input framerate.
  • --list-nets [optional] Print all supported networks for this application (from networks.json) and exit.
  • --list-inputs: [optional] Print the available predefined input resources (images/videos) defined in inputs.json for this application, then exit.

Example

  • List supported networks:

    ./build/x86_64/pose_estimation --list-nets
  • List available input resources:

    ./build/x86_64/pose_estimation --list-inputs
  • For a video:

    ./build/x86_64/pose_estimation --net yolov8m_pose.hef --input full_mov_slow.mp4 --batch-size 16

    Output video is saved as processed_video.mp4

  • For a single image:

    ./build/x86_64/pose_estimation -n yolov8m_pose.hef -i zidane.jpg

    Output image is saved as processed_image_0.jpg

  • For a directory of images:

    ./build/x86_64/pose_estimation -n yolov8m_pose.hef -i images -b 4

    Each image is saved as processed_image_i.jpg

  • For camera, enabling saving the output:

    ./build/x86_64/pose_estimation --net yolov8m_pose.hef --input /dev/video0 --batch-size 2 -s

    Output video is saved as processed_video.mp4

Notes

  • This example was built for YOLOv8_pose trained on a single class (person), To use YOLOv8_pose models trained on multiple classes, edit yolov8pose_postprocess.cpp at line 37: #define NUM_CLASSES X

  • You can tune IOU_THRESHOLD and SCORE_THRESHOLD in yolov8pose_postprocess.cpp for better detection results on different videos.

  • The script assumes that the image is in one of the following formats: .jpg, .jpeg, .png or .bmp

  • There should be no spaces between "=" given in the command line arguments and the file name itself

  • When using camera as input:

    • To exit gracefully from openCV window, press 'q'.
    • Camera path is usually found under /dev/video0.
    • Ensure you have the permissions for the camera. You may need to run, for example:
      sudo chmod 777 /dev/video0
    • In case OpenCV is defaulting to GStreamer for video capture, warnings might occur. To solve, force OpenCV to use V4L2 instead of GStreamer by setting these environment variables:
        export OPENCV_VIDEOIO_PRIORITY_GSTREAMER=0
        export OPENCV_VIDEOIO_PRIORITY_V4L2=100
      
  • Using multiple models on same device:

    • If you need to run multiple models on the same virtual device (vdevice), use the AsyncModelInfer constructor that accepts two arguments. Initialize each model using the same group_id.
    • Example:
         std::string group_id = "<group_id>";
         AsyncModelInfer model1("<hef1_path>", group_id);
         AsyncModelInfer model2("<hef2_path>", group_id);
      
    • By assigning the same group_id to models from different HEF files, you enable the runtime to treat them as part of the same group, allowing them to share resources and run more efficiently on the same hardware.

Disclaimer

This code example is provided by Hailo solely on an “AS IS” basis and “with all faults”. No responsibility or liability is accepted or shall be imposed upon Hailo regarding the accuracy, merchantability, completeness or suitability of the code example. Hailo shall not have any liability or responsibility for errors or omissions in, or any business decisions made by you in reliance on this code example or any part of it. If an error occurs when running this example, please open a ticket in the "Issues" tab.

This example was tested on specific versions and we can only guarantee the expected results using the exact version mentioned above on the exact environment. The example might work for other versions, other environment or other HEF file, but there is no guarantee that it will.