Pedestrian Skeleton Detector
Maintained by NOVA
Overview
A ROS Node that uses YOLOv8 Pose Detection to detect pedestrian skeletons in real-time and publish the annotated results.
In:
- /cameras/camera0 Image
- Receives an image from the camera (topic:
cameras/camera0
).
- Receives an image from the camera (topic:
Out:
-
/processed_image Image
- Publishes the processed image with pose annotations (topic:
processed_image
).
- Publishes the processed image with pose annotations (topic:
-
/detection_status String
- Publishes the detection status, including confidence in detecting pedestrians.
Function Descriptions
image_callback(self, msg: Image)
Processes an incoming camera image, applies YOLOv8 Pose Detection, and republishes the annotated image.
Steps:
- Converts the incoming ROS Image message into an OpenCV image using
CvBridge
. - Runs YOLOv8 Pose Detection on the image.
- Extracts the detected pedestrian(s) and checks if confidence is above the threshold.
- If a pedestrian is detected, it publishes a message to the
/detection_status
topic. - Annotates the image with pose keypoints.
- Converts the annotated image back into a ROS Image message.
- Publishes the annotated image to the
/processed_image
topic. - Optionally, displays the processed image in a window for debugging.
Error Handling:
- If an unsupported image encoding is detected, logs an error message.
- If an exception occurs during processing, logs the error details.
Dependencies
rclpy
: ROS 2 Python APIsensor_msgs.msg.Image
: ROS Image message typestd_msgs.msg.String
: ROS String message type for detection statuscv_bridge
: Converts between ROS Image messages and OpenCV imagescv2
: OpenCV for image processingultralytics.YOLO
: YOLOv8 model for pose detectionnumpy
: Array operations
Usage
Launch the node and subscribe to /processed_image
to receive annotated images and /detection_status
for detection updates:
ros2 run <package_name> <node_executable>