SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
CVTrackedFaces.h
Go to the documentation of this file.
1 /**
2  * \file CVTrackedFaces.h
3  * \date Spring 2018
4  * \remarks Please use clangformat to format the code. See more code style on
5  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
6  * \authors Marcus Hudritsch, Michael Goettlicher
7  * \copyright http://opensource.org/licenses/GPL-3.0
8 */
9 
10 #ifndef CVTrackedFaces_H
11 #define CVTrackedFaces_H
12 
13 /*
14 The OpenCV library version 3.4 with extra module must be present.
15 If the application captures the live video stream with OpenCV you have
16 to define in addition the constant APP_USES_CVCAPTURE.
17 All classes that use OpenCV begin with CV.
18 See also the class docs for CVCapture, CVCalibration and CVTracked
19 for a good top down information.
20 */
21 
22 #include <CVTypedefs.h>
23 #include <CVTracked.h>
24 
26 
27 //-----------------------------------------------------------------------------
28 //! OpenCV face & facial landmark tracker class derived from CVTracked
29 /*! Tracking class for face and facial landmark tracking. The class uses the
30 OpenCV face detection algorithm from Viola-Jones to find all faces in the image
31 and the facial landmark detector provided in cv::facemark. For more details
32 see the comments in CVTrackedFaces::track method.
33 */
34 class CVTrackedFaces : public CVTracked
35 {
36 public:
37  explicit CVTrackedFaces(string faceClassifierFilename, // haarcascade_frontalface_alt2.xml
38  string faceMarkModelFilename, // lbfmodel.yaml
39  int smoothLength = 5);
41 
42  bool track(CVMat imageGray,
43  CVMat imageBgr,
44  CVCalibration* calib) final;
45 
46  static void delaunayTriangulate(CVMat imageBgr,
47  const CVVPoint2f& points,
48  bool drawDetection);
49 
50 private:
51  CVCascadeClassifier* _faceDetector; //!< Viola-Jones face detector
52  cv::Ptr<CVFacemark> _facemark; //!< Facial landmarks detector smart pointer
53  vector<AvgCVVec2f> _avgPosePoints2D; //!< vector of averaged facial landmark 2D points
54  CVRect _boundingRect; //!< Bounding rectangle around landmarks
55  CVVPoint2f _cvPosePoints2D; //!< vector of OpenCV point2D
56  CVVPoint3f _cvPosePoints3D; //!< vector of OpenCV point2D
57  int _smoothLength; //!< Smoothing filter lenght
58 };
59 //-----------------------------------------------------------------------------
60 #endif // CVTrackedFaces_H
Utils::Averaged< CVVec2f > AvgCVVec2f
vector< cv::Point3f > CVVPoint3f
Definition: CVTypedefs.h:79
cv::CascadeClassifier CVCascadeClassifier
Definition: CVTypedefs.h:66
cv::Rect CVRect
Definition: CVTypedefs.h:39
cv::Mat CVMat
Definition: CVTypedefs.h:38
vector< cv::Point2f > CVVPoint2f
Definition: CVTypedefs.h:77
Live video camera calibration class with OpenCV an OpenCV calibration.
Definition: CVCalibration.h:71
OpenCV face & facial landmark tracker class derived from CVTracked.
int _smoothLength
Smoothing filter lenght.
cv::Ptr< CVFacemark > _facemark
Facial landmarks detector smart pointer.
CVCascadeClassifier * _faceDetector
Viola-Jones face detector.
CVVPoint2f _cvPosePoints2D
vector of OpenCV point2D
vector< AvgCVVec2f > _avgPosePoints2D
vector of averaged facial landmark 2D points
bool track(CVMat imageGray, CVMat imageBgr, CVCalibration *calib) final
Tracks the a face and its landmarks.
CVRect _boundingRect
Bounding rectangle around landmarks.
CVVPoint3f _cvPosePoints3D
vector of OpenCV point2D
CVTrackedFaces(string faceClassifierFilename, string faceMarkModelFilename, int smoothLength=5)
Constructor for the facial landmark tracker.
static void delaunayTriangulate(CVMat imageBgr, const CVVPoint2f &points, bool drawDetection)
CVTracked is the pure virtual base class for tracking features in video.
Definition: CVTracked.h:50
bool drawDetection()
Definition: CVTracked.h:64
Averaged template class provides an average value from a fixed size array.
Definition: Averaged.h:32