Skip to main content
The sample_hand_detection sample application detects hands and hand landmarks from images or camera streams using Python-based ROS 2 nodes. It uses QualcommÂź AI Engine Direct SDK (QNN) for model inference. The model is sourced from the MediaPipe Hand Landmark Detector, which is a machine learning pipeline that predicts bounding boxes and pose skeletons of hands in an image. This sample application allows you to input either a static image named input_image.jpg or a live camera stream, and then it publishes the result as ROS topic /handlandmark_result.
NoteFor more information, see sample_hand_detection on GitHub.

Figure: Sample effects of sample_hand_detection

Pipeline flow for sample_hand_detection

Figure: Pipeline flow for sample_hand_detection

ROS nodes used in sample_hand_detection

ROS nodeDescription
qrb_ros_cameraQualcomm ROS 2 package that captures images with parameters and publishes them to ROS topics.
qrb_ros_nn_inferenceLoads a trained AI model, receives preprocessed images, performs inference, and publishes results.
qrb_ros_hand_detectorSubscribes to an image topic (from static image or camera), performs preprocessing and postprocessing, and publishes detection results.
palm_preprocessorPrepares input image data for palm detection by resizing, normalizing images, and converting image formats to match model requirements.
palm_postprocessorInterprets raw output from palm detection model, extracts bounding boxes and confidence scores, applies filtering and optional NMS, and maps results to original image coordinates.
landmark_preprocessorProcesses the cropped hand regions based on palm detection results. Resizes and normalizes the image, and may apply geometric transformations to align the hand orientation.
landmark_postprocessorDecodes the output of the landmark detection model, extracts hand keypoints and maps them back to the original image space.

ROS topics used in sample_hand_detection

ROS TopicTypePublished By
/handlandmark_resultsensor_msgs.msg.Imageqrb_ros_hand_detector
/palm_detector_input_tensorqrb_ros_tensor_list_msgs.msg.TensorListqrb_ros_hand_detector
/palm_detector_output_tensorqrb_ros_tensor_list_msgs.msg.TensorListqrb_ros_nn_inference
/landmark_detector_input_tensorqrb_ros_tensor_list_msgs.msg.TensorListqrb_ros_hand_detector
/landmark_detector_output_tensorqrb_ros_tensor_list_msgs.msg.TensorListqrb_ros_nn_inference
/image_rawsensor_msgs.msg.Imageqrb_ros_camera

Prerequisites

You have completed the settings in Set up the environment for running sample applications.

Run out-of-the-box sample_hand_detection

1

Run the sample on the development kit

Select the input source of the pipeline, and then complete the steps in the corresponding tab.
  1. Set up the runtime environment.
    SSH Session
  2. Launch the sample with image_publisher. You can replace image_path with the path to your desired image.
    SSH Session
2

View the results on the host computer

  1. Start the rqt.
    SSH Session
  2. Select the following buttons in sequence: Plugins —> Visualization —> Image View
  3. Select handlandmark_result to see the results.

Build and run sample_hand_detection

The following steps build the sample_hand_detection package using Dragonwing IQ-9075 Evaluation Kit as an example.
1

Build and package on the host computer

  1. Build the sample application project.
  2. Package and push the sample application to the device.
2

Install and run on the development kit

  1. Install the sample application.
    SSH Session
  2. Run the sample application with the steps in Run out-of-the-box sample_hand_detection.