Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:3a9487d57a5c 1 // This file is part of OpenCV project.
thedo 166:3a9487d57a5c 2 // It is subject to the license terms in the LICENSE file found in the top-level directory
thedo 166:3a9487d57a5c 3 // of this distribution and at http://opencv.org/license.html.
thedo 166:3a9487d57a5c 4
thedo 166:3a9487d57a5c 5 // Copyright (c) 2011,2012. Philipp Wagner <bytefish[at]gmx[dot]de>.
thedo 166:3a9487d57a5c 6 // Third party copyrights are property of their respective owners.
thedo 166:3a9487d57a5c 7
thedo 166:3a9487d57a5c 8 #ifndef __OPENCV_FACEREC_HPP__
thedo 166:3a9487d57a5c 9 #define __OPENCV_FACEREC_HPP__
thedo 166:3a9487d57a5c 10
thedo 166:3a9487d57a5c 11 #include "opencv2/face.hpp"
thedo 166:3a9487d57a5c 12 #include "opencv2/core.hpp"
thedo 166:3a9487d57a5c 13
thedo 166:3a9487d57a5c 14 namespace cv { namespace face {
thedo 166:3a9487d57a5c 15
thedo 166:3a9487d57a5c 16 //! @addtogroup face
thedo 166:3a9487d57a5c 17 //! @{
thedo 166:3a9487d57a5c 18
thedo 166:3a9487d57a5c 19 // base for two classes
thedo 166:3a9487d57a5c 20 class CV_EXPORTS_W BasicFaceRecognizer : public FaceRecognizer
thedo 166:3a9487d57a5c 21 {
thedo 166:3a9487d57a5c 22 public:
thedo 166:3a9487d57a5c 23 /** @see setNumComponents */
thedo 166:3a9487d57a5c 24 CV_WRAP virtual int getNumComponents() const = 0;
thedo 166:3a9487d57a5c 25 /** @copybrief getNumComponents @see getNumComponents */
thedo 166:3a9487d57a5c 26 CV_WRAP virtual void setNumComponents(int val) = 0;
thedo 166:3a9487d57a5c 27 /** @see setThreshold */
thedo 166:3a9487d57a5c 28 CV_WRAP virtual double getThreshold() const = 0;
thedo 166:3a9487d57a5c 29 /** @copybrief getThreshold @see getThreshold */
thedo 166:3a9487d57a5c 30 CV_WRAP virtual void setThreshold(double val) = 0;
thedo 166:3a9487d57a5c 31 CV_WRAP virtual std::vector<cv::Mat> getProjections() const = 0;
thedo 166:3a9487d57a5c 32 CV_WRAP virtual cv::Mat getLabels() const = 0;
thedo 166:3a9487d57a5c 33 CV_WRAP virtual cv::Mat getEigenValues() const = 0;
thedo 166:3a9487d57a5c 34 CV_WRAP virtual cv::Mat getEigenVectors() const = 0;
thedo 166:3a9487d57a5c 35 CV_WRAP virtual cv::Mat getMean() const = 0;
thedo 166:3a9487d57a5c 36 };
thedo 166:3a9487d57a5c 37
thedo 166:3a9487d57a5c 38 /**
thedo 166:3a9487d57a5c 39 @param num_components The number of components (read: Eigenfaces) kept for this Principal
thedo 166:3a9487d57a5c 40 Component Analysis. As a hint: There's no rule how many components (read: Eigenfaces) should be
thedo 166:3a9487d57a5c 41 kept for good reconstruction capabilities. It is based on your input data, so experiment with the
thedo 166:3a9487d57a5c 42 number. Keeping 80 components should almost always be sufficient.
thedo 166:3a9487d57a5c 43 @param threshold The threshold applied in the prediction.
thedo 166:3a9487d57a5c 44
thedo 166:3a9487d57a5c 45 ### Notes:
thedo 166:3a9487d57a5c 46
thedo 166:3a9487d57a5c 47 - Training and prediction must be done on grayscale images, use cvtColor to convert between the
thedo 166:3a9487d57a5c 48 color spaces.
thedo 166:3a9487d57a5c 49 - **THE EIGENFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL
thedo 166:3a9487d57a5c 50 SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your
thedo 166:3a9487d57a5c 51 input data has the correct shape, else a meaningful exception is thrown. Use resize to resize
thedo 166:3a9487d57a5c 52 the images.
thedo 166:3a9487d57a5c 53 - This model does not support updating.
thedo 166:3a9487d57a5c 54
thedo 166:3a9487d57a5c 55 ### Model internal data:
thedo 166:3a9487d57a5c 56
thedo 166:3a9487d57a5c 57 - num_components see createEigenFaceRecognizer.
thedo 166:3a9487d57a5c 58 - threshold see createEigenFaceRecognizer.
thedo 166:3a9487d57a5c 59 - eigenvalues The eigenvalues for this Principal Component Analysis (ordered descending).
thedo 166:3a9487d57a5c 60 - eigenvectors The eigenvectors for this Principal Component Analysis (ordered by their
thedo 166:3a9487d57a5c 61 eigenvalue).
thedo 166:3a9487d57a5c 62 - mean The sample mean calculated from the training data.
thedo 166:3a9487d57a5c 63 - projections The projections of the training data.
thedo 166:3a9487d57a5c 64 - labels The threshold applied in the prediction. If the distance to the nearest neighbor is
thedo 166:3a9487d57a5c 65 larger than the threshold, this method returns -1.
thedo 166:3a9487d57a5c 66 */
thedo 166:3a9487d57a5c 67 CV_EXPORTS_W Ptr<BasicFaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
thedo 166:3a9487d57a5c 68
thedo 166:3a9487d57a5c 69 /**
thedo 166:3a9487d57a5c 70 @param num_components The number of components (read: Fisherfaces) kept for this Linear
thedo 166:3a9487d57a5c 71 Discriminant Analysis with the Fisherfaces criterion. It's useful to keep all components, that
thedo 166:3a9487d57a5c 72 means the number of your classes c (read: subjects, persons you want to recognize). If you leave
thedo 166:3a9487d57a5c 73 this at the default (0) or set it to a value less-equal 0 or greater (c-1), it will be set to the
thedo 166:3a9487d57a5c 74 correct number (c-1) automatically.
thedo 166:3a9487d57a5c 75 @param threshold The threshold applied in the prediction. If the distance to the nearest neighbor
thedo 166:3a9487d57a5c 76 is larger than the threshold, this method returns -1.
thedo 166:3a9487d57a5c 77
thedo 166:3a9487d57a5c 78 ### Notes:
thedo 166:3a9487d57a5c 79
thedo 166:3a9487d57a5c 80 - Training and prediction must be done on grayscale images, use cvtColor to convert between the
thedo 166:3a9487d57a5c 81 color spaces.
thedo 166:3a9487d57a5c 82 - **THE FISHERFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL
thedo 166:3a9487d57a5c 83 SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your
thedo 166:3a9487d57a5c 84 input data has the correct shape, else a meaningful exception is thrown. Use resize to resize
thedo 166:3a9487d57a5c 85 the images.
thedo 166:3a9487d57a5c 86 - This model does not support updating.
thedo 166:3a9487d57a5c 87
thedo 166:3a9487d57a5c 88 ### Model internal data:
thedo 166:3a9487d57a5c 89
thedo 166:3a9487d57a5c 90 - num_components see createFisherFaceRecognizer.
thedo 166:3a9487d57a5c 91 - threshold see createFisherFaceRecognizer.
thedo 166:3a9487d57a5c 92 - eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending).
thedo 166:3a9487d57a5c 93 - eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their
thedo 166:3a9487d57a5c 94 eigenvalue).
thedo 166:3a9487d57a5c 95 - mean The sample mean calculated from the training data.
thedo 166:3a9487d57a5c 96 - projections The projections of the training data.
thedo 166:3a9487d57a5c 97 - labels The labels corresponding to the projections.
thedo 166:3a9487d57a5c 98 */
thedo 166:3a9487d57a5c 99 CV_EXPORTS_W Ptr<BasicFaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
thedo 166:3a9487d57a5c 100
thedo 166:3a9487d57a5c 101 class CV_EXPORTS_W LBPHFaceRecognizer : public FaceRecognizer
thedo 166:3a9487d57a5c 102 {
thedo 166:3a9487d57a5c 103 public:
thedo 166:3a9487d57a5c 104 /** @see setGridX */
thedo 166:3a9487d57a5c 105 CV_WRAP virtual int getGridX() const = 0;
thedo 166:3a9487d57a5c 106 /** @copybrief getGridX @see getGridX */
thedo 166:3a9487d57a5c 107 CV_WRAP virtual void setGridX(int val) = 0;
thedo 166:3a9487d57a5c 108 /** @see setGridY */
thedo 166:3a9487d57a5c 109 CV_WRAP virtual int getGridY() const = 0;
thedo 166:3a9487d57a5c 110 /** @copybrief getGridY @see getGridY */
thedo 166:3a9487d57a5c 111 CV_WRAP virtual void setGridY(int val) = 0;
thedo 166:3a9487d57a5c 112 /** @see setRadius */
thedo 166:3a9487d57a5c 113 CV_WRAP virtual int getRadius() const = 0;
thedo 166:3a9487d57a5c 114 /** @copybrief getRadius @see getRadius */
thedo 166:3a9487d57a5c 115 CV_WRAP virtual void setRadius(int val) = 0;
thedo 166:3a9487d57a5c 116 /** @see setNeighbors */
thedo 166:3a9487d57a5c 117 CV_WRAP virtual int getNeighbors() const = 0;
thedo 166:3a9487d57a5c 118 /** @copybrief getNeighbors @see getNeighbors */
thedo 166:3a9487d57a5c 119 CV_WRAP virtual void setNeighbors(int val) = 0;
thedo 166:3a9487d57a5c 120 /** @see setThreshold */
thedo 166:3a9487d57a5c 121 CV_WRAP virtual double getThreshold() const = 0;
thedo 166:3a9487d57a5c 122 /** @copybrief getThreshold @see getThreshold */
thedo 166:3a9487d57a5c 123 CV_WRAP virtual void setThreshold(double val) = 0;
thedo 166:3a9487d57a5c 124 CV_WRAP virtual std::vector<cv::Mat> getHistograms() const = 0;
thedo 166:3a9487d57a5c 125 CV_WRAP virtual cv::Mat getLabels() const = 0;
thedo 166:3a9487d57a5c 126 };
thedo 166:3a9487d57a5c 127
thedo 166:3a9487d57a5c 128 /**
thedo 166:3a9487d57a5c 129 @param radius The radius used for building the Circular Local Binary Pattern. The greater the
thedo 166:3a9487d57a5c 130 radius, the
thedo 166:3a9487d57a5c 131 @param neighbors The number of sample points to build a Circular Local Binary Pattern from. An
thedo 166:3a9487d57a5c 132 appropriate value is to use `8` sample points. Keep in mind: the more sample points you include,
thedo 166:3a9487d57a5c 133 the higher the computational cost.
thedo 166:3a9487d57a5c 134 @param grid_x The number of cells in the horizontal direction, 8 is a common value used in
thedo 166:3a9487d57a5c 135 publications. The more cells, the finer the grid, the higher the dimensionality of the resulting
thedo 166:3a9487d57a5c 136 feature vector.
thedo 166:3a9487d57a5c 137 @param grid_y The number of cells in the vertical direction, 8 is a common value used in
thedo 166:3a9487d57a5c 138 publications. The more cells, the finer the grid, the higher the dimensionality of the resulting
thedo 166:3a9487d57a5c 139 feature vector.
thedo 166:3a9487d57a5c 140 @param threshold The threshold applied in the prediction. If the distance to the nearest neighbor
thedo 166:3a9487d57a5c 141 is larger than the threshold, this method returns -1.
thedo 166:3a9487d57a5c 142
thedo 166:3a9487d57a5c 143 ### Notes:
thedo 166:3a9487d57a5c 144
thedo 166:3a9487d57a5c 145 - The Circular Local Binary Patterns (used in training and prediction) expect the data given as
thedo 166:3a9487d57a5c 146 grayscale images, use cvtColor to convert between the color spaces.
thedo 166:3a9487d57a5c 147 - This model supports updating.
thedo 166:3a9487d57a5c 148
thedo 166:3a9487d57a5c 149 ### Model internal data:
thedo 166:3a9487d57a5c 150
thedo 166:3a9487d57a5c 151 - radius see createLBPHFaceRecognizer.
thedo 166:3a9487d57a5c 152 - neighbors see createLBPHFaceRecognizer.
thedo 166:3a9487d57a5c 153 - grid_x see createLBPHFaceRecognizer.
thedo 166:3a9487d57a5c 154 - grid_y see createLBPHFaceRecognizer.
thedo 166:3a9487d57a5c 155 - threshold see createLBPHFaceRecognizer.
thedo 166:3a9487d57a5c 156 - histograms Local Binary Patterns Histograms calculated from the given training data (empty if
thedo 166:3a9487d57a5c 157 none was given).
thedo 166:3a9487d57a5c 158 - labels Labels corresponding to the calculated Local Binary Patterns Histograms.
thedo 166:3a9487d57a5c 159 */
thedo 166:3a9487d57a5c 160 CV_EXPORTS_W Ptr<LBPHFaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8, double threshold = DBL_MAX);
thedo 166:3a9487d57a5c 161
thedo 166:3a9487d57a5c 162 //! @}
thedo 166:3a9487d57a5c 163
thedo 166:3a9487d57a5c 164 }} //namespace cv::face
thedo 166:3a9487d57a5c 165
thedo 166:3a9487d57a5c 166 #endif //__OPENCV_FACEREC_HPP__
thedo 166:3a9487d57a5c 167