Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
FacialLandmarksCV.h
1#pragma once
2
3#include <opencv2/face.hpp>
4#include "Module.h"
5
6class Detail;
7class DetailSSD;
9
11{
12public:
18
20
21 FacialLandmarkCVProps(FaceDetectionModelType _type, const std::string _Face_Detection_Configuration, const std::string _Face_Detection_Weights, const std::string _landmarksDetectionModel, cv::Ptr<cv::face::Facemark> _facemark)
22 : type(_type), Face_Detection_Configuration(_Face_Detection_Configuration), Face_Detection_Weights(_Face_Detection_Weights), landmarksDetectionModel(_landmarksDetectionModel),facemark(_facemark)
23 {
24 if (_type != FaceDetectionModelType::SSD)
25 {
26 throw AIPException(AIP_FATAL, "This constructor only supports SSD");
27 }
28 }
29
30 FacialLandmarkCVProps(FaceDetectionModelType _type, const std::string _faceDetectionModel,const std::string _landmarksDetectionModel, cv::Ptr<cv::face::Facemark> _facemark)
31 : type(_type), landmarksDetectionModel(_landmarksDetectionModel), faceDetectionModel(_faceDetectionModel), facemark(_facemark)
32 {
34 {
35 throw AIPException(AIP_FATAL, "This constructor only supports HAAR_CASCADE ");
36 }
37 }
38
40 const std::string Face_Detection_Configuration = "./data/assets/deploy.prototxt";
41 const std::string Face_Detection_Weights = "./data/assets/res10_300x300_ssd_iter_140000_fp16.caffemodel";
42 const std::string landmarksDetectionModel = "./data/assets/face_landmark_model.dat";
43 const std::string faceDetectionModel = "./data/assets/haarcascade.xml";
44 cv::Ptr<cv::face::Facemark> facemark = cv::face::FacemarkKazemi::create();
45
47 {
48 return ModuleProps::getSerializeSize() + sizeof(type);
49 }
50
51private:
53
54 template <class Archive>
55 void serialize(Archive& ar, const unsigned int version)
56 {
57 ar& boost::serialization::base_object<ModuleProps>(*this);
58 ar& type;
59 }
60};
61
63{
64 public:
66 virtual ~FacialLandmarkCV();
67 bool init();
68 bool term();
71
72protected:
73 bool process(frame_container &frames);
74 bool processSOS(frame_sp &frame);
75 bool validateInputPins();
76 bool validateOutputPins();
77 void addInputPin(framemetadata_sp &metadata, string &pinId); // throws exception if validation fails
78 bool shouldTriggerSOS();
79 bool processEOS(string &pinId);
80 boost::shared_ptr<Detail> mDetail;
82 bool handlePropsChange(frame_sp& frame);
83 std::string mOutputPinId1;
84};
Definition FacialLandmarksCV.cpp:157
Definition FacialLandmarksCV.cpp:99
Definition FacialLandmarksCV.cpp:17
Definition FacialLandmarksCV.h:11
FacialLandmarkCVProps(FaceDetectionModelType _type, const std::string _faceDetectionModel, const std::string _landmarksDetectionModel, cv::Ptr< cv::face::Facemark > _facemark)
Definition FacialLandmarksCV.h:30
const std::string faceDetectionModel
Definition FacialLandmarksCV.h:43
FaceDetectionModelType
Definition FacialLandmarksCV.h:14
@ SSD
Definition FacialLandmarksCV.h:15
@ HAAR_CASCADE
Definition FacialLandmarksCV.h:16
FacialLandmarkCVProps(FaceDetectionModelType _type, const std::string _Face_Detection_Configuration, const std::string _Face_Detection_Weights, const std::string _landmarksDetectionModel, cv::Ptr< cv::face::Facemark > _facemark)
Definition FacialLandmarksCV.h:21
const std::string Face_Detection_Configuration
Definition FacialLandmarksCV.h:40
FaceDetectionModelType type
Definition FacialLandmarksCV.h:39
void serialize(Archive &ar, const unsigned int version)
Definition FacialLandmarksCV.h:55
size_t getSerializeSize()
Definition FacialLandmarksCV.h:46
cv::Ptr< cv::face::Facemark > facemark
Definition FacialLandmarksCV.h:44
const std::string landmarksDetectionModel
Definition FacialLandmarksCV.h:42
FacialLandmarkCVProps(FaceDetectionModelType _type)
Definition FacialLandmarksCV.h:19
friend class boost::serialization::access
Definition FacialLandmarksCV.h:52
const std::string Face_Detection_Weights
Definition FacialLandmarksCV.h:41
Definition FacialLandmarksCV.h:63
boost::shared_ptr< Detail > mDetail
Definition FacialLandmarksCV.h:80
void setProps(FacialLandmarkCVProps &props)
Definition FacialLandmarksCV.cpp:331
bool process(frame_container &frames)
Definition FacialLandmarksCV.cpp:278
bool validateInputPins()
Definition FacialLandmarksCV.cpp:189
FacialLandmarkCVProps getProps()
Definition FacialLandmarksCV.cpp:336
bool processSOS(frame_sp &frame)
Definition FacialLandmarksCV.cpp:311
bool term()
Definition FacialLandmarksCV.cpp:272
std::string mOutputPinId1
Definition FacialLandmarksCV.h:83
FacialLandmarkCV(FacialLandmarkCVProps props)
Definition FacialLandmarksCV.cpp:185
bool shouldTriggerSOS()
Definition FacialLandmarksCV.cpp:320
FacialLandmarkCVProps mProp
Definition FacialLandmarksCV.h:81
void addInputPin(framemetadata_sp &metadata, string &pinId)
Definition FacialLandmarksCV.cpp:241
bool validateOutputPins()
Definition FacialLandmarksCV.cpp:215
bool handlePropsChange(frame_sp &frame)
Definition FacialLandmarksCV.cpp:342
virtual ~FacialLandmarkCV()
Definition FacialLandmarksCV.cpp:187
bool processEOS(string &pinId)
Definition FacialLandmarksCV.cpp:325
bool init()
Definition FacialLandmarksCV.cpp:248
Definition Module.h:33
virtual size_t getSerializeSize()
Definition Module.h:101
Definition Module.h:151