From: Eric Christiansen Date: Thu, 26 Jul 2012 23:55:54 +0000 (-0700) Subject: asserted in LBPH code that images must have a single channel X-Git-Tag: accepted/2.0/20130307.220821~364^2~307 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f08996bd37f7f80fc22d3c59073c80bc3fc37222;p=profile%2Fivi%2Fopencv.git asserted in LBPH code that images must have a single channel --- diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index 6966068..6676728 100644 --- a/modules/contrib/src/facerec.cpp +++ b/modules/contrib/src/facerec.cpp @@ -734,6 +734,12 @@ void LBPH::train(InputArray _src, InputArray _lbls) { // get the vector of matrices vector src; _src.getMatVector(src); + for (vector::const_iterator image = src.begin(); image != src.end(); ++image) { + if (image->channels() != 1) { + string error_message = format("The images must be single channel (grayscale), but an image has %d channels.", image->channels()); + CV_Error(CV_StsUnsupportedFormat, error_message); + } + } // turn the label matrix into a vector Mat labels = _lbls.getMat(); CV_Assert( labels.type() == CV_32S && (labels.cols == 1 || labels.rows == 1)); @@ -760,6 +766,10 @@ void LBPH::train(InputArray _src, InputArray _lbls) { void LBPH::predict(InputArray _src, int &minClass, double &minDist) const { Mat src = _src.getMat(); + if (src.channels() != 1) { + string error_message = format("The image must be single channel (grayscale), but the image has %d channels.", src.channels()); + CV_Error(CV_StsUnsupportedFormat, error_message); + } // get the spatial histogram from input image Mat lbp_image = elbp(src, _radius, _neighbors); Mat query = spatial_histogram(