diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index 183338a9bf..78e4af43a2 100644 --- a/modules/contrib/src/facerec.cpp +++ b/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_(src,dst); break; + case CV_8UC1: olbp_(src,dst); break; + case CV_16SC1: olbp_(src,dst); break; + case CV_16UC1: olbp_(src,dst); break; + case CV_32SC1: olbp_(src,dst); break; + case CV_32FC1: olbp_(src,dst); break; + case CV_64FC1: olbp_(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,15 +639,19 @@ 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()) { - case CV_8SC1: elbp_(src,dst, radius, neighbors); break; - case CV_8UC1: elbp_(src, dst, radius, neighbors); break; - case CV_16SC1: elbp_(src,dst, radius, neighbors); break; - case CV_16UC1: elbp_(src,dst, radius, neighbors); break; - case CV_32SC1: elbp_(src,dst, radius, neighbors); break; - case CV_32FC1: elbp_(src,dst, radius, neighbors); break; - case CV_64FC1: elbp_(src,dst, radius, neighbors); break; - default: break; + int type = src.type(); + switch (type) { + case CV_8SC1: elbp_(src,dst, radius, neighbors); break; + case CV_8UC1: elbp_(src, dst, radius, neighbors); break; + case CV_16SC1: elbp_(src,dst, radius, neighbors); break; + case CV_16UC1: elbp_(src,dst, radius, neighbors); break; + case CV_32SC1: elbp_(src,dst, radius, neighbors); break; + case CV_32FC1: elbp_(src,dst, radius, neighbors); break; + case CV_64FC1: elbp_(src,dst, radius, neighbors); 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; } }