sequence_face_landmarks
Utility for sequence face landmarks
utilities.h File Reference

Sequence face landmarks utility functions. More...

#include "sequence_face_landmarks.h"

Go to the source code of this file.

Classes

struct  sfl::FaceStat
 Represents a face statistics in the sequence. More...
 

Functions

void sfl::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. More...
 
void sfl::render (cv::Mat &img, const cv::Rect &bbox, const cv::Scalar &color=cv::Scalar(0, 255, 0), int thickness=1)
 Render bounding box. More...
 
void sfl::render (cv::Mat &img, const Face &face, bool drawIDs=true, bool drawLabels=false, const cv::Scalar &bbox_color=cv::Scalar(0, 0, 255), const cv::Scalar &landmarks_color=cv::Scalar(0, 255, 0), int thickness=1, double fontScale=1.0)
 Render face's bounding box and landmarks. More...
 
void sfl::render (cv::Mat &img, const Frame &frame, bool drawIDs=true, bool drawLabels=false, const cv::Scalar &bbox_color=cv::Scalar(0, 0, 255), const cv::Scalar &landmarks_color=cv::Scalar(0, 255, 0), int thickness=1, double fontScale=1.0)
 Render all frame faces including bounding boxs and landmarks. More...
 
void sfl::renderFaceID (cv::Mat &img, const Face &face, const cv::Scalar &color, int thickness=1, double fontScale=1.0)
 
void sfl::getSequenceStats (const std::list< std::unique_ptr< Frame >> &sequence, std::vector< FaceStat > &stats)
 Get the face statistics of the sequence. More...
 
int sfl::getMainFaceID (const std::list< std::unique_ptr< Frame >> &sequence)
 Get the main face in a sequence.
 
int sfl::getMainFaceID (const std::vector< FaceStat > &stats)
 Get the main face from face statistics.
 
cv::Point2f sfl::getFaceLeftEye (const std::vector< cv::Point > &landmarks)
 Get the face's left eye center position (right eye in the image). More...
 
cv::Point2f sfl::getFaceRightEye (const std::vector< cv::Point > &landmarks)
 Get the face's right eye center position (left eye in the image). More...
 
float sfl::getFaceApproxVertAngle (const std::vector< cv::Point > &landmarks)
 Get the face's vertical angle [radians]. More...
 
float sfl::getFaceApproxHorAngle (const std::vector< cv::Point > &landmarks)
 Get the face's horizontal angle [radians]. More...
 
float sfl::getFaceApproxTiltAngle (const std::vector< cv::Point > &landmarks)
 Get the face's tilt angle [radians]. More...
 
cv::Point3f sfl::getFaceApproxEulerAngles (const std::vector< cv::Point > &landmarks)
 Get the face's euler angles [radians]. More...
 
cv::Rect sfl::getFaceBBoxFromLandmarks (const std::vector< cv::Point > &landmarks, const cv::Size &frameSize, bool square)
 Get face bounding box from landmarks. More...
 
void sfl::createFullFace (const std::vector< cv::Point > &landmarks, std::vector< cv::Point > &full_face)
 Create full face points from landmarks. More...
 

Detailed Description

Sequence face landmarks utility functions.

Function Documentation

void sfl::createFullFace ( const std::vector< cv::Point > &  landmarks,
std::vector< cv::Point > &  full_face 
)

Create full face points from landmarks.

This will add the forehead part of the face.

Parameters
landmarksFace points.
full_faceThe full face points.
cv::Point3f sfl::getFaceApproxEulerAngles ( const std::vector< cv::Point > &  landmarks)

Get the face's euler angles [radians].

The angles are in the range [-75/180*pi, 75/180*pi].

Parameters
landmarks68 face points.
Returns
Return a vector with the 3 euler angles. The x axis represents vertical rotation angle, up is positive. The y axis represents horizontal rotation angle, right is positive. The z axis represents tilt rotation angle, left is positive.
float sfl::getFaceApproxHorAngle ( const std::vector< cv::Point > &  landmarks)

Get the face's horizontal angle [radians].

The angles are in the range [-75/180*pi, 75/180*pi]. When the face is looking right (left in the image) the angle will be positive and when it is looking left (right in the image) it will be negative.

Parameters
landmarks68 face points.
float sfl::getFaceApproxTiltAngle ( const std::vector< cv::Point > &  landmarks)

Get the face's tilt angle [radians].

The angles are in the range [-75/180*pi, 75/180*pi]. When the face is tilting left (right in the image) the angle will be positive and when it is tilting right (left in the image) it will be negative.

Parameters
landmarks68 face points.
float sfl::getFaceApproxVertAngle ( const std::vector< cv::Point > &  landmarks)

Get the face's vertical angle [radians].

The angles are in the range [-75/180*pi, 75/180*pi]. When the face is looking up the angle will be positive and when it is looking down it will be negative.

Parameters
landmarks68 face points.
cv::Rect sfl::getFaceBBoxFromLandmarks ( const std::vector< cv::Point > &  landmarks,
const cv::Size &  frameSize,
bool  square 
)

Get face bounding box from landmarks.

Parameters
landmarksFace points.
frameSizeThe size of the image.
squareMake the bounding box square (limited to frame boundaries).
cv::Point2f sfl::getFaceLeftEye ( const std::vector< cv::Point > &  landmarks)

Get the face's left eye center position (right eye in the image).

Parameters
landmarks68 face points.
cv::Point2f sfl::getFaceRightEye ( const std::vector< cv::Point > &  landmarks)

Get the face's right eye center position (left eye in the image).

Parameters
landmarks68 face points.
void sfl::getSequenceStats ( const std::list< std::unique_ptr< Frame >> &  sequence,
std::vector< FaceStat > &  stats 
)

Get the face statistics of the sequence.

Parameters
sequenceThe sequence of frames to calculate the statistics for.
statsOutput vector of statistics for each face in the sequence.
void sfl::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.

Parameters
imgThe image that the landmarks will be rendered on.
landmarksThe landmark points to render.
drawLabelsif true, for each landmark, it's 0 based index will be rendererd as a label.
colorLine/point and label color.
thicknessLine/point thickness.
void sfl::render ( cv::Mat &  img,
const cv::Rect &  bbox,
const cv::Scalar &  color = cv::Scalar(0, 255, 0),
int  thickness = 1 
)

Render bounding box.

Parameters
imgThe image that the bounding box will be rendered on.
bboxThe bounding box rectangle to render.
colorLine color.
thicknessLine thickness.
void sfl::render ( cv::Mat &  img,
const Face face,
bool  drawIDs = true,
bool  drawLabels = false,
const cv::Scalar &  bbox_color = cv::Scalar(0, 0, 255),
const cv::Scalar &  landmarks_color = cv::Scalar(0, 255, 0),
int  thickness = 1,
double  fontScale = 1.0 
)

Render face's bounding box and landmarks.

Parameters
imgThe image that the face will be rendered on.
faceThe face to render.
drawIDsif true, the 0 based id will be rendererd as a label.
drawLabelsif true, for each landmark, it's 0 based index will be rendererd as a label.
bbox_colorBounding box line color.
landmarks_colorLandmarks line/point and label color.
thicknessLine/point thickness.
fontScaleThe size of the font for the labels.
void sfl::render ( cv::Mat &  img,
const Frame frame,
bool  drawIDs = true,
bool  drawLabels = false,
const cv::Scalar &  bbox_color = cv::Scalar(0, 0, 255),
const cv::Scalar &  landmarks_color = cv::Scalar(0, 255, 0),
int  thickness = 1,
double  fontScale = 1.0 
)

Render all frame faces including bounding boxs and landmarks.

Parameters
imgThe image that the faces will be rendered on.
frameThe frame to render.
drawIDsif true, the 0 based id will be rendererd as a label.
drawLabelsif true, for each landmark, it's 0 based index will be rendererd as a label.
bbox_colorBounding box line color.
landmarks_colorLandmarks line/point and label color.
thicknessLine/point thickness.
fontScaleThe size of the font for the labels.