the last step of add uniform lbp to opencv Lib

asked 2017-03-15 03:06:05 -0500

sabra gravatar image

updated 2017-03-15 03:07:28 -0500

i add below code to LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserveData) after produced the mat lbp_image (in opencv source)

static int uniform[256] = // for exactly 8 bits / neighbours !
{  
0,1,2,3,4,58,5,6,7,58,58,58,8,58,9,10,11,58,58,58,58,58,58,58,12,58,58,58,13,58,14,15,16,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,17,58,58,58,58,58,58,58,18,58,58,58,19,58,20,21,22,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,23,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,24,58,58,58,58,58,58,58,25,58,58,58,26,58,27,28,29,30,58,31,58,58,58,32,58,58,58,58,58,58,58,33,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,34,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,35,36,37,58,38,58,58,58,39,58,58,58,58,58,58,58,40,58,58,58,58,58,58,58,58,58,58,58,58,58,58,58,41,42,43,58,44,58,58,58,45,58,58,58,58,58,58,58,46,47,48,58,49,58,58,58,50,51,52,58,53,54,55,56,57};

Mat out;
Mat lookup(1,256,CV_32S, uniform); // make a Mat from it
LUT(lbp_image,lookup,lbp_image);

then also the number of histogram bins from 256 to 59 like below :

   Mat p = spatial_histogram(
                lbp_image, /* lbp_image */
                static_cast<int>(59), /* number of possible patterns */
                _grid_x, /* grid size x */
                _grid_y, /* grid size y */
true);

but i got this error :

assertion failed : (lutcn == cn || lutcn == 1) && lut.total() == 256 && lut.isContinuous() && (src.depth() == CV_8U || src.depth() == CV_8S) in function LUT

i know that problem is in : src.depth() == CV_8U || src.depth() == CV_8S)

please help me in detail that what changes are need, im a begginer in opencv

edit retag flag offensive close merge delete

Comments

static uchar uniform[] will solve the problem? @berak

sabra gravatar imagesabra ( 2017-03-15 06:28:05 -0500 )edit