vector<int> getLabelsByString(const string& str);
};
+ // The FaceRecognizerBase class is introduced to keep the FaceRecognizer binary backward compatibility in 2.4
+ // In master setLabelInfo/getLabelInfo/getLabelsByString should be virtual and _labelsInfo should be moved to FaceRecognizer
+ // that allows to avoid FaceRecognizer2 in master
+ class FaceRecognizer2 : public FaceRecognizer
+ {
+ protected:
+ // Stored pairs "label id - string info"
+ std::map<int, string> _labelsInfo;
+
+ public:
+ // Sets additional information as pairs label - info.
+ virtual void setLabelsInfo(const std::map<int, string>& labelsInfo);
+
+ // Gets string information by label
+ virtual string getLabelInfo(int label) const;
+
+ // Gets labels by string
+ virtual vector<int> getLabelsByString(const string& str);
+ };
+
CV_EXPORTS_W Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
CV_EXPORTS_W Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
CV_EXPORTS_W Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8,
return elems;
}
-// This class was introduced to avoid an addition of new virtual functions in FaceRecognizer class.
-// It is safe for a binary compatibility.
-class FaceRecognizerBase : public FaceRecognizer
-{
-protected:
- // Stored pairs "label id - string info"
- std::map<int, string> _labelsInfo;
-
-public:
- // Sets additional information as pairs label - info.
- virtual void setLabelsInfo(const std::map<int, string>& labelsInfo);
-
- // Gets string information by label
- virtual string getLabelInfo(int label) const;
-
- // Gets labels by string
- virtual vector<int> getLabelsByString(const string& str);
-};
-
-void FaceRecognizerBase::setLabelsInfo(const std::map<int,string>& labelsInfo)
+void FaceRecognizer2::setLabelsInfo(const std::map<int,string>& labelsInfo)
{
_labelsInfo = labelsInfo;
}
-string FaceRecognizerBase::getLabelInfo(int label) const
+string FaceRecognizer2::getLabelInfo(int label) const
{
std::map<int, string>::const_iterator iter(_labelsInfo.find(label));
return iter != _labelsInfo.end() ? iter->second : "";
}
-vector<int> FaceRecognizerBase::getLabelsByString(const string& str)
+vector<int> FaceRecognizer2::getLabelsByString(const string& str)
{
vector<int> labels;
for(std::map<int,string>::const_iterator it = _labelsInfo.begin(); it != _labelsInfo.end(); it++)
// Turk, M., and Pentland, A. "Eigenfaces for recognition.". Journal of
// Cognitive Neuroscience 3 (1991), 71–86.
-class Eigenfaces : public FaceRecognizerBase
+class Eigenfaces : public FaceRecognizer2
{
private:
int _num_components;
// faces: Recognition using class specific linear projection.". IEEE
// Transactions on Pattern Analysis and Machine Intelligence 19, 7 (1997),
// 711–720.
-class Fisherfaces: public FaceRecognizerBase
+class Fisherfaces: public FaceRecognizer2
{
private:
int _num_components;
// patterns: Application to face recognition." IEEE Transactions on Pattern
// Analysis and Machine Intelligence, 28(12):2037-2041.
//
-class LBPH : public FaceRecognizerBase
+class LBPH : public FaceRecognizer2
{
private:
int _grid_x;
void FaceRecognizer::setLabelsInfo(const std::map<int, string>& labelsInfo)
{
- FaceRecognizerBase* base = dynamic_cast<FaceRecognizerBase*>(this);
+ FaceRecognizer2* base = dynamic_cast<FaceRecognizer2*>(this);
CV_Assert(base != 0);
base->setLabelsInfo(labelsInfo);
}
string FaceRecognizer::getLabelInfo(const int &label)
{
- FaceRecognizerBase* base = dynamic_cast<FaceRecognizerBase*>(this);
+ FaceRecognizer2* base = dynamic_cast<FaceRecognizer2*>(this);
CV_Assert(base != 0);
return base->getLabelInfo(label);
}
vector<int> FaceRecognizer::getLabelsByString(const string& str)
{
- FaceRecognizerBase* base = dynamic_cast<FaceRecognizerBase*>(this);
+ FaceRecognizer2* base = dynamic_cast<FaceRecognizer2*>(this);
CV_Assert(base != 0);
return base->getLabelsByString(str);
}