rosfacedetect
This file is ai generated. Do not edit this file directly. Instead, edit the node source code and run the generate-node-docs command to update this file.
Description
Computer vision node that performs real-time face detection on incoming image streams using OpenCV’s Haar cascade classifiers. The node subscribes to both regular and compressed image topics, detects faces in the images, draws bounding boxes around detected faces, and displays the results in OpenCV windows. This demonstrates the integration of OpenCV computer vision algorithms with ROS2 image pipelines.
Subscribers
-t/--topic(default:/camera/rgb/image_raw) (sensor_msgs/msg/Image)Raw image topic for face detection
-s/--ctopic(default:/camera/rgb/image/compressed) (sensor_msgs/msg/CompressedImage)Compressed image topic for face detection
Parameters
The node accepts command-line options (not ROS2 parameters):
-c/--cascade: Path to Haar cascade XML file (default:/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml)-t/--topic: Topic name for raw images (default:/camera/rgb/image_raw)-s/--ctopic: Topic name for compressed images (default:/camera/rgb/image/compressed)
Example Usage
Run face detection with default settings:
ros2 run opencv_tests rosfacedetect
Specify a custom image topic:
ros2 run opencv_tests rosfacedetect --topic /camera/image
Use a different Haar cascade file and custom topics:
ros2 run opencv_tests rosfacedetect \
--cascade /path/to/haarcascade.xml \
--topic /my_camera/image_raw \
--ctopic /my_camera/image/compressed
The node will display detected faces in real-time in two OpenCV windows named “result” (for raw images) and “compressed_result” (for compressed images). Press ‘q’ or ESC to exit.