facerec.cpp: Added an exception to the LBP extraction, so now a meaningful exception is thrown if the wrong image type was given. Thanks to Eric Christiansen for reporting.

pull/8/head
Philipp Wagner 12 years ago
parent 5f2ce22fbf
commit 4a4f90c406
  1. 25
      modules/contrib/src/facerec.cpp

@ -578,6 +578,23 @@ void olbp_(InputArray _src, OutputArray _dst) {
}
}
static void olbp(InputArray src, OutputArray dst) {
int type = src.getMat().type();
switch (type) {
case CV_8SC1: olbp_<char>(src,dst); break;
case CV_8UC1: olbp_<unsigned char>(src,dst); break;
case CV_16SC1: olbp_<short>(src,dst); break;
case CV_16UC1: olbp_<unsigned short>(src,dst); break;
case CV_32SC1: olbp_<int>(src,dst); break;
case CV_32FC1: olbp_<float>(src,dst); break;
case CV_64FC1: olbp_<double>(src,dst); break;
default:
string error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type);
CV_Error(CV_StsNotImplemented, error_msg);
break;
}
}
//------------------------------------------------------------------------------
// cv::elbp
@ -622,7 +639,8 @@ inline void elbp_(InputArray _src, OutputArray _dst, int radius, int neighbors)
static void elbp(InputArray src, OutputArray dst, int radius, int neighbors)
{
switch (src.type()) {
int type = src.type();
switch (type) {
case CV_8SC1: elbp_<char>(src,dst, radius, neighbors); break;
case CV_8UC1: elbp_<unsigned char>(src, dst, radius, neighbors); break;
case CV_16SC1: elbp_<short>(src,dst, radius, neighbors); break;
@ -630,7 +648,10 @@ static void elbp(InputArray src, OutputArray dst, int radius, int neighbors)
case CV_32SC1: elbp_<int>(src,dst, radius, neighbors); break;
case CV_32FC1: elbp_<float>(src,dst, radius, neighbors); break;
case CV_64FC1: elbp_<double>(src,dst, radius, neighbors); break;
default: break;
default:
string error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type);
CV_Error(CV_StsNotImplemented, error_msg);
break;
}
}

Loading…
Cancel
Save