From 6dba6955c5f76ba61b9b9d565aae3b49b952aa4a Mon Sep 17 00:00:00 2001 From: Jared Swift Date: Thu, 1 Feb 2024 16:52:51 +0000 Subject: [PATCH] feat: learn face service. --- .../vision/lasr_vision_deepface/nodes/service | 20 +++++++++++++++++-- common/vision/lasr_vision_msgs/CMakeLists.txt | 1 + .../vision/lasr_vision_msgs/srv/LearnFace.srv | 10 ++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 common/vision/lasr_vision_msgs/srv/LearnFace.srv diff --git a/common/vision/lasr_vision_deepface/nodes/service b/common/vision/lasr_vision_deepface/nodes/service index 12149844c..f8126287f 100644 --- a/common/vision/lasr_vision_deepface/nodes/service +++ b/common/vision/lasr_vision_deepface/nodes/service @@ -4,7 +4,15 @@ import re import rospy import lasr_vision_deepface as face_recognition from sensor_msgs.msg import Image -from lasr_vision_msgs.srv import Recognise, RecogniseRequest, RecogniseResponse +from lasr_vision_msgs.srv import ( + Recognise, + RecogniseRequest, + RecogniseResponse, + LearnFace, + LearnFaceRequest, + LearnFaceResponse, +) + rospy.init_node("recognise_service") @@ -29,6 +37,14 @@ def detect(request: RecogniseRequest) -> RecogniseResponse: return face_recognition.detect(request, debug_publisher) +def learn_face(request: LearnFaceRequest) -> LearnFaceResponse: + face_recognition.learn_face( + "/xtion/rgb/image_raw", request.dataset, request.name, request.n_images + ) + return LearnFaceResponse() + + rospy.Service("/recognise", Recognise, detect) -rospy.loginfo("Face Recognition service starter") +rospy.Service("/learn_face", LearnFace, learn_face) +rospy.loginfo("Face Recognition service started") rospy.spin() diff --git a/common/vision/lasr_vision_msgs/CMakeLists.txt b/common/vision/lasr_vision_msgs/CMakeLists.txt index 0f781a520..f5a0101e8 100644 --- a/common/vision/lasr_vision_msgs/CMakeLists.txt +++ b/common/vision/lasr_vision_msgs/CMakeLists.txt @@ -60,6 +60,7 @@ add_service_files( BodyPixDetection.srv TorchFaceFeatureDetection.srv Recognise.srv + LearnFace.srv ) ## Generate actions in the 'action' folder diff --git a/common/vision/lasr_vision_msgs/srv/LearnFace.srv b/common/vision/lasr_vision_msgs/srv/LearnFace.srv new file mode 100644 index 000000000..5376e53d5 --- /dev/null +++ b/common/vision/lasr_vision_msgs/srv/LearnFace.srv @@ -0,0 +1,10 @@ +# Name to associate +string name + +# Dataset to add face to +string dataset + +# Number of images to take +int32 n_images + +---