face_alignment.hpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #ifndef __OPENCV_FACE_ALIGNMENT_HPP__
  5. #define __OPENCV_FACE_ALIGNMENT_HPP__
  6. #include "opencv2/face/facemark_train.hpp"
  7. namespace cv{
  8. namespace face{
  9. class CV_EXPORTS_W FacemarkKazemi : public Facemark
  10. {
  11. public:
  12. struct CV_EXPORTS Params
  13. {
  14. /**
  15. * \brief Constructor
  16. */
  17. Params();
  18. /// cascade_depth This stores the deapth of cascade used for training.
  19. unsigned long cascade_depth;
  20. /// tree_depth This stores the max height of the regression tree built.
  21. unsigned long tree_depth;
  22. /// num_trees_per_cascade_level This stores number of trees fit per cascade level.
  23. unsigned long num_trees_per_cascade_level;
  24. /// learning_rate stores the learning rate in gradient boosting, also referred as shrinkage.
  25. float learning_rate;
  26. /// oversampling_amount stores number of initialisations used to create training samples.
  27. unsigned long oversampling_amount;
  28. /// num_test_coordinates stores number of test coordinates.
  29. unsigned long num_test_coordinates;
  30. /// lambda stores a value to calculate probability of closeness of two coordinates.
  31. float lambda;
  32. /// num_test_splits stores number of random test splits generated.
  33. unsigned long num_test_splits;
  34. /// configfile stores the name of the file containing the values of training parameters
  35. String configfile;
  36. };
  37. static Ptr<FacemarkKazemi> create(const FacemarkKazemi::Params &parameters = FacemarkKazemi::Params());
  38. virtual ~FacemarkKazemi();
  39. /** @brief This function is used to train the model using gradient boosting to get a cascade of regressors
  40. *which can then be used to predict shape.
  41. *@param images A vector of type cv::Mat which stores the images which are used in training samples.
  42. *@param landmarks A vector of vectors of type cv::Point2f which stores the landmarks detected in a particular image.
  43. *@param scale A size of type cv::Size to which all images and landmarks have to be scaled to.
  44. *@param configfile A variable of type std::string which stores the name of the file storing parameters for training the model.
  45. *@param modelFilename A variable of type std::string which stores the name of the trained model file that has to be saved.
  46. *@returns A boolean value. The function returns true if the model is trained properly or false if it is not trained.
  47. */
  48. virtual bool training(std::vector<Mat>& images, std::vector< std::vector<Point2f> >& landmarks,std::string configfile,Size scale,std::string modelFilename = "face_landmarks.dat")=0;
  49. /// set the custom face detector
  50. virtual bool setFaceDetector(bool(*f)(InputArray , OutputArray, void*), void* userData)=0;
  51. /// get faces using the custom detector
  52. virtual bool getFaces(InputArray image, OutputArray faces)=0;
  53. };
  54. }} // namespace
  55. #endif