facemark.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /*
  5. This file was part of GSoC Project: Facemark API for OpenCV
  6. Final report: https://gist.github.com/kurnianggoro/74de9121e122ad0bd825176751d47ecc
  7. Student: Laksono Kurnianggoro
  8. Mentor: Delia Passalacqua
  9. */
  10. #ifndef __OPENCV_FACELANDMARK_HPP__
  11. #define __OPENCV_FACELANDMARK_HPP__
  12. /**
  13. @defgroup face Face Analysis
  14. - @ref tutorial_table_of_content_facemark
  15. - The Facemark API
  16. */
  17. #include "opencv2/core.hpp"
  18. #include <vector>
  19. namespace cv {
  20. namespace face {
  21. /** @brief Abstract base class for all facemark models
  22. To utilize this API in your program, please take a look at the @ref tutorial_table_of_content_facemark
  23. ### Description
  24. Facemark is a base class which provides universal access to any specific facemark algorithm.
  25. Therefore, the users should declare a desired algorithm before they can use it in their application.
  26. Here is an example on how to declare a facemark algorithm:
  27. @code
  28. // Using Facemark in your code:
  29. Ptr<Facemark> facemark = createFacemarkLBF();
  30. @endcode
  31. The typical pipeline for facemark detection is as follows:
  32. - Load the trained model using Facemark::loadModel.
  33. - Perform the fitting on an image via Facemark::fit.
  34. */
  35. class CV_EXPORTS_W Facemark : public virtual Algorithm
  36. {
  37. public:
  38. /** @brief A function to load the trained model before the fitting process.
  39. @param model A string represent the filename of a trained model.
  40. <B>Example of usage</B>
  41. @code
  42. facemark->loadModel("../data/lbf.model");
  43. @endcode
  44. */
  45. CV_WRAP virtual void loadModel( String model ) = 0;
  46. // virtual void saveModel(String fs)=0;
  47. /** @brief Detect facial landmarks from an image.
  48. @param image Input image.
  49. @param faces Output of the function which represent region of interest of the detected faces.
  50. Each face is stored in cv::Rect container.
  51. @param landmarks The detected landmark points for each faces.
  52. <B>Example of usage</B>
  53. @code
  54. Mat image = imread("image.jpg");
  55. std::vector<Rect> faces;
  56. std::vector<std::vector<Point2f> > landmarks;
  57. facemark->fit(image, faces, landmarks);
  58. @endcode
  59. */
  60. CV_WRAP virtual bool fit( InputArray image,
  61. InputArray faces,
  62. OutputArrayOfArrays landmarks ) = 0;
  63. }; /* Facemark*/
  64. //! construct an AAM facemark detector
  65. CV_EXPORTS_W Ptr<Facemark> createFacemarkAAM();
  66. //! construct an LBF facemark detector
  67. CV_EXPORTS_W Ptr<Facemark> createFacemarkLBF();
  68. //! construct a Kazemi facemark detector
  69. CV_EXPORTS_W Ptr<Facemark> createFacemarkKazemi();
  70. } // face
  71. } // cv
  72. #endif //__OPENCV_FACELANDMARK_HPP__