face_recognition
Recognizes the faces detected by face_detection with the face recognizers of opencv_contrib (Eigenfaces, Fisherfaces or LBPH), trained with the ~/train service.
opencv_apps |
1.12.0 and later (ROS 1), 3.0.0 and later (ROS 2) |
|---|---|
ROS |
noetic, ROS One, jazzy, kilted, lyrical and later |
OpenCV |
any version of the distributions |
Group |
Faces, the nodes of which publish |
Usage
# ROS 2
ros2 launch opencv_apps face_recognition.launch.xml image:=/camera/image_raw debug_view:=false
# ROS 1
roslaunch opencv_apps face_recognition.launch image:=/camera/image_raw debug_view:=false use_opencv4:=true
Try it with the demo video
Download the input video of the demo above, publish it as image with image_publisher, and run the node on it, in the terminals:
wget https://raw.githubusercontent.com/ros-perception/opencv_apps/indigo/test/face_detector_withface_test_diamondback.mp4
wget https://raw.githubusercontent.com/ros-perception/opencv_apps/indigo/test/face_data.tar.gz
tar xzf face_data.tar.gz
# terminal 1: publish the video as image in a loop
ros2 run image_publisher image_publisher_node face_detector_withface_test_diamondback.mp4 --ros-args -p publish_rate:=10.0 -r image_raw:=image
# terminal 2: run the node with the parameters of the demo
ros2 launch opencv_apps face_recognition.launch.xml image:=image data_dir:=$PWD/face_data launch_face_detection:=true launch_trainer:=false
# terminal 3: view the result
ros2 run rqt_image_view rqt_image_view /face_recognition/debug_image
The faces trained in test/face_data.tar.gz; ~debug_image is shown.
See Credits of the demo videos for the license of the video.
Subscribed topics
Topic |
Type |
|---|---|
|
|
|
|
Published topics
Topic |
Type |
Note |
|---|---|---|
|
|
|
|
Recommended, opencv_apps 3.0.1 and later. The same as |
|
|
Kept for compatibility, use |
Services
Service |
Type |
|---|---|
|
|
Parameters
See also the common parameters.
Name |
Type |
Default (range) |
Changed at run time |
Description |
|---|---|---|---|---|
|
bool |
false |
no, restart the node |
|
|
string |
“~/.ros/opencv_apps/face_data” |
yes |
Save directory for train data |
|
int |
90 (30 - 500) |
yes |
Height of training face image |
|
int |
190 (30 - 500) |
yes |
Width of training face image |
|
double |
0.1 (0 - 2) |
yes |
Padding ratio of each face |
|
int |
8 (1 - 30) |
yes |
grid_x parameter used only for LBPH model |
|
int |
8 (1 - 30) |
yes |
grid_y parameter used only for LBPH model |
|
int |
8 (1 - 30) |
yes |
Neighbors parameter used only for LBPH model |
|
int |
1 (1 - 10) |
yes |
Radius parameter used only for LBPH model |
|
string |
“eigen” |
yes |
Method to recognize faces, “eigen”: eigen, “fisher”: fisher, “LBPH”: LBPH |
|
int |
0 (0 - 100) |
yes |
Number of components for face recognizer model |
|
double |
8000.0 (0 - 10000) |
yes |
Threshold for face recognizer model |
|
int |
100 |
no, restart the node |
Specigy queue_size of input image subscribers |
|
bool |
true |
yes |
Save train data |
|
bool |
true |
yes |
Use saved data |
Source
src/nodelet/face_recognition_nodelet.cpp, launch/face_recognition.launch.xml