Commit 7b544d2a authored by Philipp Wagner's avatar Philipp Wagner

Documentation for FaceRecognizer started (not added to toc of…

Documentation for FaceRecognizer started (not added to toc of contrib/doc/contrib.rst yet). CSV file for the samples/cpp/facerec_demo.cpp added. Added some more exceptions to warn the user, when passing bad aligned data.
parent 5349fa03
This diff is collapsed.
...@@ -318,6 +318,15 @@ void Eigenfaces::train(InputArray _src, InputArray _local_labels) { ...@@ -318,6 +318,15 @@ void Eigenfaces::train(InputArray _src, InputArray _local_labels) {
string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type()); string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type());
CV_Error(CV_StsBadArg, error_message); CV_Error(CV_StsBadArg, error_message);
} }
// make sure data has correct size
if(_src.total() > 1) {
for(int i = 1; i < static_cast<int>(_src.total()); i++) {
if(_src.getMat(i-1).total() != _src.getMat(i).total()) {
string error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total());
CV_Error(CV_StsUnsupportedFormat, error_message);
}
}
}
// get labels // get labels
Mat labels = _local_labels.getMat(); Mat labels = _local_labels.getMat();
// observations in row // observations in row
...@@ -412,6 +421,15 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) { ...@@ -412,6 +421,15 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) {
string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type()); string error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type());
CV_Error(CV_StsBadArg, error_message); CV_Error(CV_StsBadArg, error_message);
} }
// make sure data has correct size
if(src.total() > 1) {
for(int i = 1; i < static_cast<int>(src.total()); i++) {
if(src.getMat(i-1).total() != src.getMat(i).total()) {
string error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total());
CV_Error(CV_StsUnsupportedFormat, error_message);
}
}
}
// get data // get data
Mat labels = _lbls.getMat(); Mat labels = _lbls.getMat();
Mat data = asRowMatrix(src, CV_64FC1); Mat data = asRowMatrix(src, CV_64FC1);
...@@ -425,8 +443,7 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) { ...@@ -425,8 +443,7 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) {
string error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols); string error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols);
CV_Error(CV_StsBadArg, error_message); CV_Error(CV_StsBadArg, error_message);
} }
// Get the number of unique classes // Get the number of unique classes (provide a cv::Mat overloaded version?)
// TODO Provide a cv::Mat version?
vector<int> ll; vector<int> ll;
labels.copyTo(ll); labels.copyTo(ll);
int C = (int) remove_dups(ll).size(); int C = (int) remove_dups(ll).size();
......
This diff is collapsed.
...@@ -116,9 +116,8 @@ int main(int argc, const char *argv[]) { ...@@ -116,9 +116,8 @@ int main(int argc, const char *argv[]) {
// test image: // test image:
int predictedLabel = model->predict(testSample); int predictedLabel = model->predict(testSample);
// //
// To get the confidence of a prediction call it with: // To get the confidence of a prediction call the model with:
// //
// model with:
// int predictedLabel = -1; // int predictedLabel = -1;
// double confidence = 0.0; // double confidence = 0.0;
// model->predict(testSample, predictedLabel, confidence); // model->predict(testSample, predictedLabel, confidence);
......
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