Commit f29d73fe authored by Philipp Wagner's avatar Philipp Wagner

Updated the train method to be an InputArrayOfArrays, so the Python wrapper now…

Updated the train method to be an InputArrayOfArrays, so the Python wrapper now generates the correct code (and it works).
parent b2deab21
...@@ -925,7 +925,7 @@ namespace cv ...@@ -925,7 +925,7 @@ namespace cv
virtual ~FaceRecognizer() {} virtual ~FaceRecognizer() {}
// Trains a FaceRecognizer. // Trains a FaceRecognizer.
CV_WRAP virtual void train(InputArray src, InputArray labels) = 0; CV_WRAP virtual void train(InputArrayOfArrays src, InputArray labels) = 0;
// Gets a prediction from a FaceRecognizer. // Gets a prediction from a FaceRecognizer.
virtual int predict(InputArray src) const = 0; virtual int predict(InputArray src) const = 0;
......
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
// Initializes and computes an Eigenfaces model with images in src and // Initializes and computes an Eigenfaces model with images in src and
// corresponding labels in labels. num_components will be kept for // corresponding labels in labels. num_components will be kept for
// classification. // classification.
Eigenfaces(InputArray src, InputArray labels, Eigenfaces(InputArrayOfArrays src, InputArray labels,
int num_components = 0, double threshold = DBL_MAX) : int num_components = 0, double threshold = DBL_MAX) :
_num_components(num_components), _num_components(num_components),
_threshold(threshold) { _threshold(threshold) {
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
// Computes an Eigenfaces model with images in src and corresponding labels // Computes an Eigenfaces model with images in src and corresponding labels
// in labels. // in labels.
void train(InputArray src, InputArray labels); void train(InputArrayOfArrays src, InputArray labels);
// Predicts the label of a query image in src. // Predicts the label of a query image in src.
int predict(InputArray src) const; int predict(InputArray src) const;
...@@ -177,7 +177,7 @@ public: ...@@ -177,7 +177,7 @@ public:
// Initializes and computes a Fisherfaces model with images in src and // Initializes and computes a Fisherfaces model with images in src and
// corresponding labels in labels. num_components will be kept for // corresponding labels in labels. num_components will be kept for
// classification. // classification.
Fisherfaces(InputArray src, InputArray labels, Fisherfaces(InputArrayOfArrays src, InputArray labels,
int num_components = 0, double threshold = DBL_MAX) : int num_components = 0, double threshold = DBL_MAX) :
_num_components(num_components), _num_components(num_components),
_threshold(threshold) { _threshold(threshold) {
...@@ -188,7 +188,7 @@ public: ...@@ -188,7 +188,7 @@ public:
// Computes a Fisherfaces model with images in src and corresponding labels // Computes a Fisherfaces model with images in src and corresponding labels
// in labels. // in labels.
void train(InputArray src, InputArray labels); void train(InputArrayOfArrays src, InputArray labels);
// Predicts the label of a query image in src. // Predicts the label of a query image in src.
int predict(InputArray src) const; int predict(InputArray src) const;
...@@ -246,7 +246,7 @@ public: ...@@ -246,7 +246,7 @@ public:
// //
// (radius=1), (neighbors=8) are used in the local binary patterns creation. // (radius=1), (neighbors=8) are used in the local binary patterns creation.
// (grid_x=8), (grid_y=8) controls the grid size of the spatial histograms. // (grid_x=8), (grid_y=8) controls the grid size of the spatial histograms.
LBPH(InputArray src, LBPH(InputArrayOfArrays src,
InputArray labels, InputArray labels,
int radius_=1, int neighbors_=8, int radius_=1, int neighbors_=8,
int gridx=8, int gridy=8, int gridx=8, int gridy=8,
...@@ -263,7 +263,7 @@ public: ...@@ -263,7 +263,7 @@ public:
// Computes a LBPH model with images in src and // Computes a LBPH model with images in src and
// corresponding labels in labels. // corresponding labels in labels.
void train(InputArray src, InputArray labels); void train(InputArrayOfArrays src, InputArray labels);
// Predicts the label of a query image in src. // Predicts the label of a query image in src.
int predict(InputArray src) const; int predict(InputArray src) const;
...@@ -306,11 +306,10 @@ void FaceRecognizer::load(const string& filename) { ...@@ -306,11 +306,10 @@ void FaceRecognizer::load(const string& filename) {
fs.release(); fs.release();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Eigenfaces // Eigenfaces
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Eigenfaces::train(InputArray _src, InputArray _local_labels) { void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
if(_src.total() == 0) { if(_src.total() == 0) {
string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); string error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
CV_Error(CV_StsBadArg, error_message); CV_Error(CV_StsBadArg, error_message);
...@@ -417,7 +416,7 @@ void Eigenfaces::save(FileStorage& fs) const { ...@@ -417,7 +416,7 @@ void Eigenfaces::save(FileStorage& fs) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Fisherfaces // Fisherfaces
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Fisherfaces::train(InputArray src, InputArray _lbls) { void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
if(src.total() == 0) { if(src.total() == 0) {
string error_message = format("Empty training data was given. You'll need more than one sample to learn a model."); string error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
CV_Error(CV_StsBadArg, error_message); CV_Error(CV_StsBadArg, error_message);
...@@ -728,7 +727,7 @@ void LBPH::save(FileStorage& fs) const { ...@@ -728,7 +727,7 @@ void LBPH::save(FileStorage& fs) const {
fs << "labels" << _labels; fs << "labels" << _labels;
} }
void LBPH::train(InputArray _src, InputArray _lbls) { void LBPH::train(InputArrayOfArrays _src, InputArray _lbls) {
if(_src.kind() != _InputArray::STD_VECTOR_MAT && _src.kind() != _InputArray::STD_VECTOR_VECTOR) { if(_src.kind() != _InputArray::STD_VECTOR_MAT && _src.kind() != _InputArray::STD_VECTOR_VECTOR) {
string error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >)."; string error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >).";
CV_Error(CV_StsBadArg, error_message); CV_Error(CV_StsBadArg, error_message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment