// make sure the input data is a vector of matrices or vector of vector
if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
string error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< vector<...> >).";
- error(Exception(CV_StsBadArg, error_message, "asRowMatrix", __FILE__, __LINE__));
+ CV_Error(CV_StsBadArg, error_message);
}
// number of samples
size_t n = src.total();
// make sure data can be reshaped, throw exception if not!
if(src.getMat(i).total() != d) {
string error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total());
- error(Exception(CV_StsBadArg, error_message, "cv::asRowMatrix", __FILE__, __LINE__));
+ CV_Error(CV_StsBadArg, error_message);
}
// get a hold of the current row
Mat xi = data.row(i);
// corresponding labels in labels. num_components will be kept for
// classification.
Eigenfaces(InputArray src, InputArray labels,
- int num_components = 0,
- double threshold = DBL_MAX) :
+ int num_components = 0, double threshold = DBL_MAX) :
_num_components(num_components),
_threshold(threshold) {
train(src, labels);
// Initializes and computes a Fisherfaces model with images in src and
// corresponding labels in labels. num_components will be kept for
// classification.
- Fisherfaces(InputArray src,
- InputArray labels,
- int num_components = 0,
- double threshold = DBL_MAX) :
+ Fisherfaces(InputArray src, InputArray labels,
+ int num_components = 0, double threshold = DBL_MAX) :
_num_components(num_components),
_threshold(threshold) {
train(src, labels);
//
// radius, neighbors are used in the local binary patterns creation.
// grid_x, grid_y control the grid size of the spatial histograms.
- LBPH(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8, double threshold = DBL_MAX) :
+ LBPH(int radius=1, int neighbors=8,
+ int grid_x=8, int grid_y=8,
+ double threshold = DBL_MAX) :
_grid_x(grid_x),
_grid_y(grid_y),
_radius(radius),
static Mat toGrayscale(InputArray _src) {
Mat src = _src.getMat();
// only allow one channel
- if(src.channels() != 1)
+ if(src.channels() != 1) {
CV_Error(CV_StsBadArg, "Only Matrices with one channel are supported");
+ }
// create and return normalized image
Mat dst;
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
// cv::Algorithm, you can query the data.
//
// First we'll use it to set the threshold of the FaceRecognizer
- // without retraining the model:
+ // to 0.0 without retraining the model. This can be useful if
+ // you are evaluating the model:
//
model->set("threshold", 0.0);
- // Now the threshold is of this model is 0.0. A prediction
- // now returns -1, as it's impossible to have a distance
- // below it
- //
+ // Now the threshold of this model is set to 0.0. A prediction
+ // now returns -1, as it's impossible to have a distance below
+ // it
predictedLabel = model->predict(testSample);
cout << "Predicted class = " << predictedLabel << endl;
- // Now here is how to get the eigenvalues of this Eigenfaces model:
+ // Here is how to get the eigenvalues of this Eigenfaces model:
Mat eigenvalues = model->getMat("eigenvalues");
// And we can do the same to display the Eigenvectors (read Eigenfaces):
Mat W = model->getMat("eigenvectors");