18 #ifndef __ICUB_FACEMODULE_MOD_H__ 19 #define __ICUB_FACEMODULE_MOD_H__ 21 #include <yarp/os/BufferedPort.h> 22 #include <yarp/os/RFModule.h> 23 #include <yarp/os/Network.h> 24 #include <yarp/os/Thread.h> 25 #include <yarp/os/RateThread.h> 26 #include <yarp/os/Time.h> 27 #include <yarp/os/Semaphore.h> 28 #include <yarp/os/Stamp.h> 29 #include <yarp/os/Os.h> 30 #include <yarp/os/Log.h> 31 #include <yarp/os/LogStream.h> 32 #include <yarp/os/RpcClient.h> 34 #include <yarp/sig/Vector.h> 35 #include <yarp/sig/Image.h> 37 #include <dlib/image_processing/frontal_face_detector.h> 38 #include <dlib/matrix/lapack/gesvd.h> 39 #include <dlib/image_processing.h> 40 #include <dlib/image_io.h> 41 #include <dlib/opencv.h> 45 #include <opencv2/imgproc/imgproc.hpp> 54 #include "faceLandmarks_IDLServer.h" 56 #define DISPLAY_LANDMARKS VOCAB4('d','i','s','p') 58 typedef struct __circle_t {
64 class FACEManager :
public yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> >
68 std::string moduleName;
69 std::string predictorFile;
70 std::string cntxHomePath;
71 std::string inImgPortName;
72 std::string outImgPortName;
73 std::string outTargetPortName;
74 std::string outLandmarksPortName;
76 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > imageInPort;
77 yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > imageOutPort;
78 yarp::os::BufferedPort<yarp::os::Bottle> targetOutPort;
79 yarp::os::BufferedPort<yarp::os::Bottle> landmarksOutPort;
83 dlib::frontal_face_detector faceDetector;
84 dlib::shape_predictor sp;
87 cv::Point leftEye, rightEye;
89 void drawLandmarks(cv::Mat &mat,
const dlib::full_object_detection &d);
97 FACEManager(
const std::string &moduleName,
const std::string &predictorFile,
const std::string &cntxHomePath );
100 yarp::os::Semaphore mutex;
101 bool displayLandmarks;
104 bool displayDarkMode;
108 void onRead( yarp::sig::ImageOf<yarp::sig::PixelRgb> &img );
110 bool execReq(
const yarp::os::Bottle &command, yarp::os::Bottle &reply);
116 std::string moduleName;
117 std::string predictorFile;
118 std::string handlerPortName;
119 yarp::os::RpcServer rpcPort;
122 FACEManager *faceManager;
124 std::string cntxHomePath;
128 bool configure(yarp::os::ResourceFinder &rf);
129 bool interruptModule();
139 bool attach(yarp::os::RpcServer &source);
143 bool display(
const std::string& element,
const std::string& value);
virtual bool display(const std::string &element, const std::string &value)
faceLandmarks_IDLServer Interface.
virtual bool quit()
Quit the module.