Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
FaceDetectorXform.h
1#pragma once
2
3#include "Module.h"
4#include <boost/serialization/vector.hpp>
5#include <array>
6#include <map>
7#include <vector>
8#include <algorithm>
9#include "declarative/PropertyMacros.h"
10
12{
13public:
14 FaceDetectorXformProps(double _scaleFactor = 1.0, float _confidenceThreshold = 0.5) : scaleFactor(_scaleFactor), confidenceThreshold(_confidenceThreshold)
15 {
16 }
19
21 {
23 }
24
25 // ============================================================
26 // Property Binding for Declarative Pipeline
27 // Both properties are Dynamic (can change at runtime)
28 // ============================================================
29 template<typename PropsT>
30 static void applyProperties(
31 PropsT& props,
32 const std::map<std::string, apra::ScalarPropertyValue>& values,
33 std::vector<std::string>& missingRequired
34 ) {
35 // scaleFactor is optional (has default)
36 apra::applyProp(props.scaleFactor, "scaleFactor", values, false, missingRequired);
37 // confidenceThreshold is optional (has default)
38 apra::applyProp(props.confidenceThreshold, "confidenceThreshold", values, false, missingRequired);
39 }
40
41 // Runtime property getter
42 apra::ScalarPropertyValue getProperty(const std::string& propName) const {
43 if (propName == "scaleFactor") return scaleFactor;
44 if (propName == "confidenceThreshold") return static_cast<double>(confidenceThreshold);
45 throw std::runtime_error("Unknown property: " + propName);
46 }
47
48 // Runtime property setter (both properties are Dynamic)
49 bool setProperty(const std::string& propName, const apra::ScalarPropertyValue& value) {
50 if (propName == "scaleFactor") {
52 }
53 if (propName == "confidenceThreshold") {
55 }
56 throw std::runtime_error("Unknown property: " + propName);
57 }
58
59 // Both properties are dynamic
60 static std::vector<std::string> dynamicPropertyNames() {
61 return {"scaleFactor", "confidenceThreshold"};
62 }
63
64 // Check if a property is dynamic
65 static bool isPropertyDynamic(const std::string& propName) {
66 auto names = dynamicPropertyNames();
67 return std::find(names.begin(), names.end(), propName) != names.end();
68 }
69
70private:
72
73 template <class Archive>
74 void serialize(Archive &ar, const unsigned int version)
75 {
76 ar &boost::serialization::base_object<ModuleProps>(*this);
78 }
79};
80
82{
83public:
85 virtual ~FaceDetectorXform() {}
86
87 virtual bool init();
88 virtual bool term();
89
92
93protected:
94 bool process(frame_container &frames);
95 bool processSOS(frame_sp &frame);
96 bool validateInputPins();
97 bool validateOutputPins();
98 void setMetadata(framemetadata_sp &metadata);
99 void addInputPin(framemetadata_sp &metadata, string &pinId);
100 bool shouldTriggerSOS();
101 bool handlePropsChange(frame_sp &frame);
102
103private:
104 class Detail;
105 boost::shared_ptr<Detail> mDetail;
106};
Definition FacialLandmarksCV.cpp:17
Definition FaceDetectorXform.h:12
FaceDetectorXformProps(double _scaleFactor=1.0, float _confidenceThreshold=0.5)
Definition FaceDetectorXform.h:14
double scaleFactor
Definition FaceDetectorXform.h:17
void serialize(Archive &ar, const unsigned int version)
Definition FaceDetectorXform.h:74
bool setProperty(const std::string &propName, const apra::ScalarPropertyValue &value)
Definition FaceDetectorXform.h:49
apra::ScalarPropertyValue getProperty(const std::string &propName) const
Definition FaceDetectorXform.h:42
size_t getSerializeSize()
Definition FaceDetectorXform.h:20
static bool isPropertyDynamic(const std::string &propName)
Definition FaceDetectorXform.h:65
friend class boost::serialization::access
Definition FaceDetectorXform.h:71
static std::vector< std::string > dynamicPropertyNames()
Definition FaceDetectorXform.h:60
float confidenceThreshold
Definition FaceDetectorXform.h:18
static void applyProperties(PropsT &props, const std::map< std::string, apra::ScalarPropertyValue > &values, std::vector< std::string > &missingRequired)
Definition FaceDetectorXform.h:30
Definition FaceDetectorXform.h:82
bool process(frame_container &frames)
Definition FaceDetectorXform.cpp:115
FaceDetectorXform(FaceDetectorXformProps props)
Definition FaceDetectorXform.cpp:52
boost::shared_ptr< Detail > mDetail
Definition FaceDetectorXform.h:105
virtual bool init()
Definition FaceDetectorXform.cpp:93
void addInputPin(framemetadata_sp &metadata, string &pinId)
Definition FaceDetectorXform.cpp:86
void setProps(FaceDetectorXformProps &props)
Definition FaceDetectorXform.cpp:212
virtual bool term()
Definition FaceDetectorXform.cpp:110
void setMetadata(framemetadata_sp &metadata)
Definition FaceDetectorXform.cpp:157
bool validateOutputPins()
Definition FaceDetectorXform.cpp:76
FaceDetectorXformProps getProps()
Definition FaceDetectorXform.cpp:198
bool shouldTriggerSOS()
Definition FaceDetectorXform.cpp:189
bool handlePropsChange(frame_sp &frame)
Definition FaceDetectorXform.cpp:204
bool validateInputPins()
Definition FaceDetectorXform.cpp:57
bool processSOS(frame_sp &frame)
Definition FaceDetectorXform.cpp:182
virtual ~FaceDetectorXform()
Definition FaceDetectorXform.h:85
Definition Module.h:33
virtual size_t getSerializeSize()
Definition Module.h:101
Definition Module.h:151
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
bool applyFromVariant(T &member, const ScalarPropertyValue &value)
Definition PropertyMacros.h:108
std::variant< int64_t, double, bool, std::string > ScalarPropertyValue
Definition ModuleRegistry.h:30