3#include <opencv2/face.hpp>
5#include "declarative/PropertyMacros.h"
25 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)
30 throw AIPException(AIP_FATAL,
"This constructor only supports SSD");
39 throw AIPException(AIP_FATAL,
"This constructor only supports HAAR_CASCADE ");
48 cv::Ptr<cv::face::Facemark>
facemark = cv::face::FacemarkKazemi::create();
58 template<
typename PropsT>
61 const std::map<std::string, apra::ScalarPropertyValue>& values,
62 std::vector<std::string>& missingRequired
65 auto it = values.find(
"modelType");
66 if (it != values.end()) {
67 if (
auto* strVal = std::get_if<std::string>(&it->second)) {
68 if (*strVal ==
"SSD") props.type =
SSD;
69 else if (*strVal ==
"HAAR_CASCADE") props.type =
HAAR_CASCADE;
72 apra::applyProp(props.Face_Detection_Configuration,
"faceDetectionConfig", values,
false, missingRequired);
73 apra::applyProp(props.Face_Detection_Weights,
"faceDetectionWeights", values,
false, missingRequired);
74 apra::applyProp(props.landmarksDetectionModel,
"landmarksModel", values,
false, missingRequired);
75 apra::applyProp(props.faceDetectionModel,
"haarCascadeModel", values,
false, missingRequired);
79 if (propName ==
"modelType")
return type ==
SSD ? std::string(
"SSD") : std::string(
"HAAR_CASCADE");
84 throw std::runtime_error(
"Unknown property: " + propName);
99 template <
class Archive>
102 ar& boost::serialization::base_object<ModuleProps>(*
this);
118 bool process(frame_container &frames);
122 void addInputPin(framemetadata_sp &metadata,
string &pinId);
Definition FacialLandmarksCV.cpp:157
Definition FacialLandmarksCV.cpp:99
Definition FacialLandmarksCV.cpp:17
Definition FacialLandmarksCV.h:12
FacialLandmarkCVProps(FaceDetectionModelType _type, const std::string _faceDetectionModel, const std::string _landmarksDetectionModel, cv::Ptr< cv::face::Facemark > _facemark)
Definition FacialLandmarksCV.h:34
static std::vector< std::string > dynamicPropertyNames()
Definition FacialLandmarksCV.h:92
std::string Face_Detection_Weights
Definition FacialLandmarksCV.h:45
std::string faceDetectionModel
Definition FacialLandmarksCV.h:47
FacialLandmarkCVProps()
Definition FacialLandmarksCV.h:21
apra::ScalarPropertyValue getProperty(const std::string &propName) const
Definition FacialLandmarksCV.h:78
FaceDetectionModelType
Definition FacialLandmarksCV.h:15
@ SSD
Definition FacialLandmarksCV.h:16
@ HAAR_CASCADE
Definition FacialLandmarksCV.h:17
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:25
static void applyProperties(PropsT &props, const std::map< std::string, apra::ScalarPropertyValue > &values, std::vector< std::string > &missingRequired)
Definition FacialLandmarksCV.h:59
FaceDetectionModelType type
Definition FacialLandmarksCV.h:43
std::string landmarksDetectionModel
Definition FacialLandmarksCV.h:46
std::string Face_Detection_Configuration
Definition FacialLandmarksCV.h:44
void serialize(Archive &ar, const unsigned int version)
Definition FacialLandmarksCV.h:100
size_t getSerializeSize()
Definition FacialLandmarksCV.h:50
cv::Ptr< cv::face::Facemark > facemark
Definition FacialLandmarksCV.h:48
FacialLandmarkCVProps(FaceDetectionModelType _type)
Definition FacialLandmarksCV.h:23
friend class boost::serialization::access
Definition FacialLandmarksCV.h:97
bool setProperty(const std::string &propName, const apra::ScalarPropertyValue &value)
Definition FacialLandmarksCV.h:87
Definition FacialLandmarksCV.h:108
boost::shared_ptr< Detail > mDetail
Definition FacialLandmarksCV.h:125
void setProps(FacialLandmarkCVProps &props)
Definition FacialLandmarksCV.cpp:331
bool process(frame_container &frames)
Definition FacialLandmarksCV.cpp:278
bool validateInputPins()
Definition FacialLandmarksCV.cpp:189
std::string mOutputPinId
Definition FacialLandmarksCV.h:128
FacialLandmarkCVProps getProps()
Definition FacialLandmarksCV.cpp:336
bool processSOS(frame_sp &frame)
Definition FacialLandmarksCV.cpp:311
bool term()
Definition FacialLandmarksCV.cpp:272
FacialLandmarkCV(FacialLandmarkCVProps props)
Definition FacialLandmarksCV.cpp:185
bool shouldTriggerSOS()
Definition FacialLandmarksCV.cpp:320
FacialLandmarkCVProps mProp
Definition FacialLandmarksCV.h:126
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
virtual size_t getSerializeSize()
Definition Module.h:101
void applyProp(T &member, const char *propName, const std::map< std::string, ScalarPropertyValue > &values, bool isRequired, std::vector< std::string > &missingRequired)
Definition PropertyMacros.h:36
std::variant< int64_t, double, bool, std::string > ScalarPropertyValue
Definition ModuleRegistry.h:30