face: apply CV_OVERRIDE/CV_FINAL

pull/1588/head
Alexander Alekhin 7 years ago
parent 14341291b0
commit acec6955d5
  1. 6
      modules/face/include/opencv2/face.hpp
  2. 4
      modules/face/include/opencv2/face/facemark.hpp
  3. 14
      modules/face/include/opencv2/face/facerec.hpp
  4. 4
      modules/face/include/opencv2/face/predict_collector.hpp
  5. 8
      modules/face/src/bif.cpp
  6. 6
      modules/face/src/eigen_faces.cpp
  7. 14
      modules/face/src/face_alignmentimpl.hpp
  8. 18
      modules/face/src/facemarkAAM.cpp
  9. 18
      modules/face/src/facemarkLBF.cpp
  10. 6
      modules/face/src/fisher_faces.cpp
  11. 35
      modules/face/src/lbph_faces.cpp
  12. 18
      modules/face/src/mace.cpp
  13. 8
      modules/face/src/regtree.cpp
  14. 6
      modules/face/src/trainFacemark.cpp

@ -333,13 +333,13 @@ public:
Saves this model to a given FileStorage.
@param fs The FileStorage to store this FaceRecognizer to.
*/
virtual void write(FileStorage& fs) const = 0;
virtual void write(FileStorage& fs) const CV_OVERRIDE = 0;
/** @overload */
virtual void read(const FileNode& fn) = 0;
virtual void read(const FileNode& fn) CV_OVERRIDE = 0;
/** @overload */
virtual bool empty() const = 0;
virtual bool empty() const CV_OVERRIDE = 0;
/** @brief Sets string info for the specified model's label.

@ -265,8 +265,8 @@ class CV_EXPORTS_W Facemark : public virtual Algorithm
{
public:
virtual void read( const FileNode& fn )=0;
virtual void write( FileStorage& fs ) const=0;
virtual void read( const FileNode& fn ) CV_OVERRIDE = 0;
virtual void write( FileStorage& fs ) const CV_OVERRIDE = 0;
/** @brief Add one training sample to the trainer.

@ -25,18 +25,18 @@ public:
/** @copybrief getNumComponents @see getNumComponents */
CV_WRAP void setNumComponents(int val);
/** @see setThreshold */
CV_WRAP double getThreshold() const;
CV_WRAP double getThreshold() const CV_OVERRIDE;
/** @copybrief getThreshold @see getThreshold */
CV_WRAP void setThreshold(double val);
CV_WRAP void setThreshold(double val) CV_OVERRIDE;
CV_WRAP std::vector<cv::Mat> getProjections() const;
CV_WRAP cv::Mat getLabels() const;
CV_WRAP cv::Mat getEigenValues() const;
CV_WRAP cv::Mat getEigenVectors() const;
CV_WRAP cv::Mat getMean() const;
virtual void read(const FileNode& fn);
virtual void write(FileStorage& fs) const;
virtual bool empty() const;
virtual void read(const FileNode& fn) CV_OVERRIDE;
virtual void write(FileStorage& fs) const CV_OVERRIDE;
virtual bool empty() const CV_OVERRIDE;
using FaceRecognizer::read;
using FaceRecognizer::write;
@ -143,9 +143,9 @@ public:
/** @copybrief getNeighbors @see getNeighbors */
CV_WRAP virtual void setNeighbors(int val) = 0;
/** @see setThreshold */
CV_WRAP virtual double getThreshold() const = 0;
CV_WRAP virtual double getThreshold() const CV_OVERRIDE = 0;
/** @copybrief getThreshold @see getThreshold */
CV_WRAP virtual void setThreshold(double val) = 0;
CV_WRAP virtual void setThreshold(double val) CV_OVERRIDE = 0;
CV_WRAP virtual std::vector<cv::Mat> getHistograms() const = 0;
CV_WRAP virtual cv::Mat getLabels() const = 0;

@ -98,9 +98,9 @@ public:
*/
StandardCollector(double threshold_ = DBL_MAX);
/** @brief overloaded interface method */
void init(size_t size);
void init(size_t size) CV_OVERRIDE;
/** @brief overloaded interface method */
bool collect(int label, double dist);
bool collect(int label, double dist) CV_OVERRIDE;
/** @brief Returns label with minimal distance */
CV_WRAP int getMinLabel() const;
/** @brief Returns minimal distance value */

@ -91,18 +91,18 @@ const double kGaborWavelens[kNumBandsMax][2] = {
{11.5, 12.7}, {14.1, 15.4}, {16.8, 18.2}, {19.7, 21.2}
};
class BIFImpl : public cv::face::BIF {
class BIFImpl CV_FINAL : public cv::face::BIF {
public:
BIFImpl(int num_bands, int num_rotations) {
initUnits(num_bands, num_rotations);
}
virtual int getNumBands() const { return num_bands_; }
virtual int getNumBands() const CV_OVERRIDE { return num_bands_; }
virtual int getNumRotations() const { return num_rotations_; }
virtual int getNumRotations() const CV_OVERRIDE { return num_rotations_; }
virtual void compute(cv::InputArray image,
cv::OutputArray features) const;
cv::OutputArray features) const CV_OVERRIDE;
private:
struct UnitParams {

@ -43,11 +43,11 @@ public:
// Computes an Eigenfaces model with images in src and corresponding labels
// in labels.
void train(InputArrayOfArrays src, InputArray labels);
void train(InputArrayOfArrays src, InputArray labels) CV_OVERRIDE;
// Send all predict results to caller side for custom result handling
void predict(InputArray src, Ptr<PredictCollector> collector) const;
String getDefaultName() const
void predict(InputArray src, Ptr<PredictCollector> collector) const CV_OVERRIDE;
String getDefaultName() const CV_OVERRIDE
{
return "opencv_eigenfaces";
}

@ -70,12 +70,12 @@ class FacemarkKazemiImpl : public FacemarkKazemi{
public:
FacemarkKazemiImpl(const FacemarkKazemi::Params& parameters);
void loadModel(String fs);
bool setFaceDetector(FN_FaceDetector f, void* userdata);
bool getFaces(InputArray image, OutputArray faces);
bool fit(InputArray image, InputArray faces, InputOutputArray landmarks );
void training(String imageList, String groundTruth);
bool training(vector<Mat>& images, vector< vector<Point2f> >& landmarks,string filename,Size scale,string modelFilename);
void loadModel(String fs) CV_OVERRIDE;
bool setFaceDetector(FN_FaceDetector f, void* userdata) CV_OVERRIDE;
bool getFaces(InputArray image, OutputArray faces) CV_OVERRIDE;
bool fit(InputArray image, InputArray faces, InputOutputArray landmarks) CV_OVERRIDE;
void training(String imageList, String groundTruth) CV_OVERRIDE;
bool training(vector<Mat>& images, vector< vector<Point2f> >& landmarks,string filename,Size scale,string modelFilename) CV_OVERRIDE;
// Destructor for the class.
virtual ~FacemarkKazemiImpl();
@ -171,4 +171,4 @@ protected:
};
}//face
}//cv
#endif
#endif

@ -92,24 +92,24 @@ void FacemarkAAM::Params::write( cv::FileStorage& fs ) const{
class FacemarkAAMImpl : public FacemarkAAM {
public:
FacemarkAAMImpl( const FacemarkAAM::Params &parameters = FacemarkAAM::Params() );
void read( const FileNode& /*fn*/ );
void write( FileStorage& /*fs*/ ) const;
void read( const FileNode& /*fn*/ ) CV_OVERRIDE;
void write( FileStorage& /*fs*/ ) const CV_OVERRIDE;
void saveModel(String fs);
void loadModel(String fs);
void loadModel(String fs) CV_OVERRIDE;
bool setFaceDetector(bool(*f)(InputArray , OutputArray, void * ), void* userData);
bool getFaces(InputArray image, OutputArray faces);
bool setFaceDetector(bool(*f)(InputArray , OutputArray, void * ), void* userData) CV_OVERRIDE;
bool getFaces(InputArray image, OutputArray faces) CV_OVERRIDE;
bool getData(void * items);
bool getData(void * items) CV_OVERRIDE;
protected:
bool fit( InputArray image, InputArray faces, InputOutputArray landmarks, void * runtime_params);//!< from many ROIs
bool fit( InputArray image, InputArray faces, InputOutputArray landmarks, void * runtime_params) CV_OVERRIDE;//!< from many ROIs
bool fitImpl( const Mat image, std::vector<Point2f>& landmarks,const Mat R,const Point2f T,const float scale, const int sclIdx=0 );
bool addTrainingSample(InputArray image, InputArray landmarks);
void training(void* parameters);
bool addTrainingSample(InputArray image, InputArray landmarks) CV_OVERRIDE;
void training(void* parameters) CV_OVERRIDE;
Mat procrustes(std::vector<Point2f> , std::vector<Point2f> , Mat & , Scalar & , float & );
void calcMeanShape(std::vector<std::vector<Point2f> > ,std::vector<Point2f> & );

@ -102,24 +102,24 @@ class FacemarkLBFImpl : public FacemarkLBF {
public:
FacemarkLBFImpl( const FacemarkLBF::Params &parameters = FacemarkLBF::Params() );
void read( const FileNode& /*fn*/ );
void write( FileStorage& /*fs*/ ) const;
void read( const FileNode& /*fn*/ ) CV_OVERRIDE;
void write( FileStorage& /*fs*/ ) const CV_OVERRIDE;
void loadModel(String fs);
void loadModel(String fs) CV_OVERRIDE;
bool setFaceDetector(bool(*f)(InputArray , OutputArray, void * extra_params ), void* userData);
bool getFaces(InputArray image, OutputArray faces);
bool getData(void * items);
bool setFaceDetector(bool(*f)(InputArray , OutputArray, void * extra_params ), void* userData) CV_OVERRIDE;
bool getFaces(InputArray image, OutputArray faces) CV_OVERRIDE;
bool getData(void * items) CV_OVERRIDE;
Params params;
protected:
bool fit( InputArray image, InputArray faces, InputOutputArray landmarks, void * runtime_params );//!< from many ROIs
bool fit( InputArray image, InputArray faces, InputOutputArray landmarks, void * runtime_params ) CV_OVERRIDE;//!< from many ROIs
bool fitImpl( const Mat image, std::vector<Point2f> & landmarks );//!< from a face
bool addTrainingSample(InputArray image, InputArray landmarks);
void training(void* parameters);
bool addTrainingSample(InputArray image, InputArray landmarks) CV_OVERRIDE;
void training(void* parameters) CV_OVERRIDE;
Rect getBBox(Mat &img, const Mat_<double> shape);
void prepareTrainingData(Mat img, std::vector<Point2f> facePoints,

@ -38,11 +38,11 @@ public:
// Computes a Fisherfaces model with images in src and corresponding labels
// in labels.
void train(InputArrayOfArrays src, InputArray labels);
void train(InputArrayOfArrays src, InputArray labels) CV_OVERRIDE;
// Send all predict results to caller side for custom result handling
void predict(InputArray src, Ptr<PredictCollector> collector) const;
String getDefaultName() const
void predict(InputArray src, Ptr<PredictCollector> collector) const CV_OVERRIDE;
String getDefaultName() const CV_OVERRIDE
{
return "opencv_fisherfaces";
}

@ -81,40 +81,45 @@ public:
train(src, labels);
}
~LBPH() { }
~LBPH() CV_OVERRIDE { }
// Computes a LBPH model with images in src and
// corresponding labels in labels.
void train(InputArrayOfArrays src, InputArray labels);
void train(InputArrayOfArrays src, InputArray labels) CV_OVERRIDE;
// Updates this LBPH model with images in src and
// corresponding labels in labels.
void update(InputArrayOfArrays src, InputArray labels);
void update(InputArrayOfArrays src, InputArray labels) CV_OVERRIDE;
// Send all predict results to caller side for custom result handling
void predict(InputArray src, Ptr<PredictCollector> collector) const;
void predict(InputArray src, Ptr<PredictCollector> collector) const CV_OVERRIDE;
// See FaceRecognizer::write.
void read(const FileNode& fn);
void read(const FileNode& fn) CV_OVERRIDE;
// See FaceRecognizer::save.
void write(FileStorage& fs) const;
void write(FileStorage& fs) const CV_OVERRIDE;
bool empty() const {
bool empty() const CV_OVERRIDE {
return (_labels.empty());
}
String getDefaultName() const
String getDefaultName() const CV_OVERRIDE
{
return "opencv_lbphfaces";
}
CV_IMPL_PROPERTY(int, GridX, _grid_x)
CV_IMPL_PROPERTY(int, GridY, _grid_y)
CV_IMPL_PROPERTY(int, Radius, _radius)
CV_IMPL_PROPERTY(int, Neighbors, _neighbors)
CV_IMPL_PROPERTY(double, Threshold, _threshold)
CV_IMPL_PROPERTY_RO(std::vector<cv::Mat>, Histograms, _histograms)
CV_IMPL_PROPERTY_RO(cv::Mat, Labels, _labels)
inline int getGridX() const CV_OVERRIDE { return _grid_x; }
inline void setGridX(int val) CV_OVERRIDE { _grid_x = val; }
inline int getGridY() const CV_OVERRIDE { return _grid_y; }
inline void setGridY(int val) CV_OVERRIDE { _grid_y = val; }
inline int getRadius() const CV_OVERRIDE { return _radius; }
inline void setRadius(int val) CV_OVERRIDE { _radius = val; }
inline int getNeighbors() const CV_OVERRIDE { return _neighbors; }
inline void setNeighbors(int val) CV_OVERRIDE { _neighbors = val; }
inline double getThreshold() const CV_OVERRIDE { return _threshold; }
inline void setThreshold(double val) CV_OVERRIDE { _threshold = val; }
inline std::vector<cv::Mat> getHistograms() const CV_OVERRIDE { return _histograms; }
inline cv::Mat getLabels() const CV_OVERRIDE { return _labels; }
};

@ -72,7 +72,7 @@ static uint64 crc64( const uchar* data, size_t size, uint64 crc0=0 )
return ~crc;
}
struct MACEImpl : MACE {
struct MACEImpl CV_FINAL : MACE {
Mat_<Vec2d> maceFilter; // filled from compute()
Mat convFilter; // optional random convolution (cancellable)
int IMGSIZE; // images will get resized to this
@ -81,7 +81,7 @@ struct MACEImpl : MACE {
MACEImpl(int siz) : IMGSIZE(siz), threshold(DBL_MAX) {}
void salt(const String &passphrase) {
void salt(const String &passphrase) CV_OVERRIDE {
theRNG().state = ((int64)crc64((uchar*)passphrase.c_str(), passphrase.size()));
convFilter.create(IMGSIZE, IMGSIZE, CV_64F);
randn(convFilter, 0, 1.0/(IMGSIZE*IMGSIZE));
@ -257,7 +257,7 @@ struct MACEImpl : MACE {
}
// MACE interface
void train(InputArrayOfArrays input) {
void train(InputArrayOfArrays input) CV_OVERRIDE {
std::vector<Mat> images, dftImg;
input.getMatVector(images);
for (size_t i=0; i<images.size(); i++) { // cache dft images
@ -266,27 +266,27 @@ struct MACEImpl : MACE {
compute(dftImg, true);
threshold = computeThreshold(dftImg, true);
}
bool same(InputArray img) const {
bool same(InputArray img) const CV_OVERRIDE {
return correlate(img.getMat()) >= threshold;
}
// cv::Algorithm:
bool empty() const {
bool empty() const CV_OVERRIDE {
return maceFilter.empty() || IMGSIZE == 0;
}
String getDefaultName () const {
String getDefaultName () const CV_OVERRIDE {
return String("MACE");
}
void clear() {
void clear() CV_OVERRIDE {
maceFilter.release();
convFilter.release();
}
void write(cv::FileStorage &fs) const {
void write(cv::FileStorage &fs) const CV_OVERRIDE {
fs << "mace" << maceFilter;
fs << "conv" << convFilter;
fs << "threshold" << threshold;
}
void read(const cv::FileNode &fn) {
void read(const cv::FileNode &fn) CV_OVERRIDE {
fn["mace"] >> maceFilter;
fn["conv"] >> convFilter;
fn["threshold"] >> threshold;

@ -18,7 +18,7 @@ class doSum : public ParallelLoopBody
sum(sum_)
{
}
virtual void operator()( const Range& range) const
virtual void operator()( const Range& range) const CV_OVERRIDE
{
for (int j = range.start; j < range.end; ++j){
for(unsigned long k=0;k<(*samples)[j].shapeResiduals.size();k++){
@ -38,7 +38,7 @@ class modifySamples : public ParallelLoopBody
temp(temp_)
{
}
virtual void operator()( const Range& range) const
virtual void operator()( const Range& range) const CV_OVERRIDE
{
for (int j = range.start; j < range.end; ++j){
for(unsigned long k=0;k<(*samples)[j].shapeResiduals.size();k++){
@ -62,7 +62,7 @@ class splitSamples : public ParallelLoopBody
feats(feats_)
{
}
virtual void operator()( const Range& range) const
virtual void operator()( const Range& range) const CV_OVERRIDE
{
for (int i = range.start; i < range.end; ++i){
for(unsigned long j=0;j<*(num_test_splits);j++){
@ -310,4 +310,4 @@ unsigned long FacemarkKazemiImpl::divideSamples (splitr split,vector<training_sa
return i;
}
}//cv
}//face
}//face

@ -18,7 +18,7 @@ class getDiffShape : public ParallelLoopBody
samples(samples_)
{
}
virtual void operator()( const cv::Range& range) const
virtual void operator()( const cv::Range& range) const CV_OVERRIDE
{
for(size_t j = (size_t)range.start; j < (size_t)range.end; ++j){
(*samples)[j].shapeResiduals.resize((*samples)[j].current_shape.size());
@ -37,7 +37,7 @@ class getRelPixels : public ParallelLoopBody
object(object_)
{
}
virtual void operator()( const cv::Range& range) const
virtual void operator()( const cv::Range& range) const CV_OVERRIDE
{
for (size_t j = (size_t)range.start; j < (size_t)range.end; ++j){
object.getRelativePixels(((*samples)[j]).current_shape,((*samples)[j]).pixel_coordinates);
@ -345,4 +345,4 @@ bool FacemarkKazemiImpl::training(vector<Mat>& images, vector< vector<Point2f> >
return true;
}
}//cv
}//face
}//face

Loading…
Cancel
Save