facemarkLBF.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. By downloading, copying, installing or using the software you agree to this
  3. license. If you do not agree to this license, do not download, install,
  4. copy or use the software.
  5. License Agreement
  6. For Open Source Computer Vision Library
  7. (3-clause BSD License)
  8. Copyright (C) 2013, OpenCV Foundation, all rights reserved.
  9. Third party copyrights are property of their respective owners.
  10. Redistribution and use in source and binary forms, with or without modification,
  11. are permitted provided that the following conditions are met:
  12. * Redistributions of source code must retain the above copyright notice,
  13. this list of conditions and the following disclaimer.
  14. * Redistributions in binary form must reproduce the above copyright notice,
  15. this list of conditions and the following disclaimer in the documentation
  16. and/or other materials provided with the distribution.
  17. * Neither the names of the copyright holders nor the names of the contributors
  18. may be used to endorse or promote products derived from this software
  19. without specific prior written permission.
  20. This software is provided by the copyright holders and contributors "as is" and
  21. any express or implied warranties, including, but not limited to, the implied
  22. warranties of merchantability and fitness for a particular purpose are
  23. disclaimed. In no event shall copyright holders or contributors be liable for
  24. any direct, indirect, incidental, special, exemplary, or consequential damages
  25. (including, but not limited to, procurement of substitute goods or services;
  26. loss of use, data, or profits; or business interruption) however caused
  27. and on any theory of liability, whether in contract, strict liability,
  28. or tort (including negligence or otherwise) arising in any way out of
  29. the use of this software, even if advised of the possibility of such damage.
  30. This file was part of GSoC Project: Facemark API for OpenCV
  31. Final report: https://gist.github.com/kurnianggoro/74de9121e122ad0bd825176751d47ecc
  32. Student: Laksono Kurnianggoro
  33. Mentor: Delia Passalacqua
  34. */
  35. #ifndef __OPENCV_FACEMARK_LBF_HPP__
  36. #define __OPENCV_FACEMARK_LBF_HPP__
  37. #include "opencv2/face/facemark_train.hpp"
  38. namespace cv {
  39. namespace face {
  40. //! @addtogroup face
  41. //! @{
  42. class CV_EXPORTS_W FacemarkLBF : public FacemarkTrain
  43. {
  44. public:
  45. struct CV_EXPORTS Params
  46. {
  47. /**
  48. * \brief Constructor
  49. */
  50. Params();
  51. double shape_offset;
  52. //!< offset for the loaded face landmark points
  53. String cascade_face;
  54. //!< filename of the face detector model
  55. bool verbose;
  56. //!< show the training print-out
  57. int n_landmarks;
  58. //!< number of landmark points
  59. int initShape_n;
  60. //!< multiplier for augment the training data
  61. int stages_n;
  62. //!< number of refinement stages
  63. int tree_n;
  64. //!< number of tree in the model for each landmark point refinement
  65. int tree_depth;
  66. //!< the depth of decision tree, defines the size of feature
  67. double bagging_overlap;
  68. //!< overlap ratio for training the LBF feature
  69. std::string model_filename;
  70. //!< filename where the trained model will be saved
  71. bool save_model; //!< flag to save the trained model or not
  72. unsigned int seed; //!< seed for shuffling the training data
  73. std::vector<int> feats_m;
  74. std::vector<double> radius_m;
  75. std::vector<int> pupils[2];
  76. //!< index of facemark points on pupils of left and right eye
  77. Rect detectROI;
  78. void read(const FileNode& /*fn*/);
  79. void write(FileStorage& /*fs*/) const;
  80. };
  81. class BBox {
  82. public:
  83. BBox();
  84. ~BBox();
  85. BBox(double x, double y, double w, double h);
  86. Mat project(const Mat &shape) const;
  87. Mat reproject(const Mat &shape) const;
  88. double x, y;
  89. double x_center, y_center;
  90. double x_scale, y_scale;
  91. double width, height;
  92. };
  93. static Ptr<FacemarkLBF> create(const FacemarkLBF::Params &parameters = FacemarkLBF::Params() );
  94. virtual ~FacemarkLBF(){};
  95. }; /* LBF */
  96. //! @}
  97. } /* namespace face */
  98. }/* namespace cv */
  99. #endif