sequence_face_landmarks
Utility for sequence face landmarks
utilities.h
Go to the documentation of this file.
1 
5 #ifndef __SFL_UTILITIES__
6 #define __SFL_UTILITIES__
7 
8 // sfl
9 #include "sequence_face_landmarks.h"
10 
11 namespace sfl
12 {
21  void render(cv::Mat& img, const std::vector<cv::Point>& landmarks,
22  bool drawLabels = false, const cv::Scalar& color = cv::Scalar(0, 255, 0),
23  int thickness = 1);
24 
31  void render(cv::Mat& img, const cv::Rect& bbox,
32  const cv::Scalar& color = cv::Scalar(0, 255, 0), int thickness = 1);
33 
45  void render(cv::Mat& img, const Face& face, bool drawIDs = true,
46  bool drawLabels = false, const cv::Scalar& bbox_color = cv::Scalar(0, 0, 255),
47  const cv::Scalar& landmarks_color = cv::Scalar(0, 255, 0), int thickness = 1,
48  double fontScale = 1.0);
49 
61  void render(cv::Mat& img, const Frame& frame, bool drawIDs = true,
62  bool drawLabels = false, const cv::Scalar& bbox_color = cv::Scalar(0, 0, 255),
63  const cv::Scalar& landmarks_color = cv::Scalar(0, 255, 0), int thickness = 1,
64  double fontScale = 1.0);
65 
66  void renderFaceID(cv::Mat& img, const Face& face, const cv::Scalar& color, int thickness = 1,
67  double fontScale = 1.0);
68 
69 
72  struct FaceStat
73  {
74  int id = 0;
75 
76  float avg_center_dist = 0;
77  int frame_count = 0;
78  float avg_size = 0;
79 
80  float central_ratio = 0;
81  float frame_ratio = 0;
82  float size_ratio = 0;
83  };
84 
89  void getSequenceStats(const std::list<std::unique_ptr<Frame>>& sequence,
90  std::vector<FaceStat>& stats);
91 
94  int getMainFaceID(const std::list<std::unique_ptr<Frame>>& sequence);
95 
98  int getMainFaceID(const std::vector<FaceStat>& stats);
99 
103  cv::Point2f getFaceLeftEye(const std::vector<cv::Point>& landmarks);
104 
108  cv::Point2f getFaceRightEye(const std::vector<cv::Point>& landmarks);
109 
116  float getFaceApproxVertAngle(const std::vector<cv::Point>& landmarks);
117 
124  float getFaceApproxHorAngle(const std::vector<cv::Point>& landmarks);
125 
132  float getFaceApproxTiltAngle(const std::vector<cv::Point>& landmarks);
133 
142  cv::Point3f getFaceApproxEulerAngles(const std::vector<cv::Point>& landmarks);
143 
149  cv::Rect getFaceBBoxFromLandmarks(const std::vector<cv::Point>& landmarks,
150  const cv::Size& frameSize, bool square);
151 
157  void createFullFace(const std::vector<cv::Point>& landmarks,
158  std::vector<cv::Point>& full_face);
159 
160 } // namespace sfl
161 
162 #endif // __SFL_UTILITIES__
float getFaceApproxVertAngle(const std::vector< cv::Point > &landmarks)
Get the face&#39;s vertical angle [radians].
int frame_count
Frames appeared in.
Definition: utilities.h:77
float frame_ratio
frame_count / total_frames
Definition: utilities.h:81
void getSequenceStats(const std::list< std::unique_ptr< Frame >> &sequence, std::vector< FaceStat > &stats)
Get the face statistics of the sequence.
float getFaceApproxTiltAngle(const std::vector< cv::Point > &landmarks)
Get the face&#39;s tilt angle [radians].
float getFaceApproxHorAngle(const std::vector< cv::Point > &landmarks)
Get the face&#39;s horizontal angle [radians].
int getMainFaceID(const std::list< std::unique_ptr< Frame >> &sequence)
Get the main face in a sequence.
cv::Point2f getFaceRightEye(const std::vector< cv::Point > &landmarks)
Get the face&#39;s right eye center position (left eye in the image).
float central_ratio
avg_center_dist / (||(avg_width, avg_height)|| / 4).
Definition: utilities.h:80
cv::Rect getFaceBBoxFromLandmarks(const std::vector< cv::Point > &landmarks, const cv::Size &frameSize, bool square)
Get face bounding box from landmarks.
float avg_size
Average face&#39;s bounding box size.
Definition: utilities.h:78
float avg_center_dist
Average distance from frame center.
Definition: utilities.h:76
cv::Point2f getFaceLeftEye(const std::vector< cv::Point > &landmarks)
Get the face&#39;s left eye center position (right eye in the image).
cv::Point3f getFaceApproxEulerAngles(const std::vector< cv::Point > &landmarks)
Get the face&#39;s euler angles [radians].
void render(cv::Mat &img, const std::vector< cv::Point > &landmarks, bool drawLabels=false, const cv::Scalar &color=cv::Scalar(0, 255, 0), int thickness=1)
Render landmarks.
void createFullFace(const std::vector< cv::Point > &landmarks, std::vector< cv::Point > &full_face)
Create full face points from landmarks.
Represents a face statistics in the sequence.
Definition: utilities.h:72
Definition: face_tracker.h:10
float size_ratio
avg_size / ((avg_width + avg_height) / 4)
Definition: utilities.h:82