Convert Gray image into LBP image
Hello everyone,
I want to detect the eye blink in android OpenCV. I have been suggested to use LBP and SVM Classification for better results. I have been looking at different places including this and this but having trouble in understanding the code. I want the code in Java and I am having problems in converting the C++ code into Java as there are some function which are different in both of them. Can someone kindly give me a sample code to convert gray image to LBP image so that I can apply SVM on it. Need it badly. Please help..help.. Here is a code in C++. I need this in Java.
Mat LBP(Mat img){
Mat dst = Mat::zeros(img.rows-2, img.cols-2, CV_8UC1);
for(int i=1;i<img.rows-1;i++) {
for(int j=1;j<img.cols-1;j++) {
uchar center = img.at<uchar>(i,j);
unsigned char code = 0;
code |= ((img.at<uchar>(i-1,j-1)) > center) << 7;
code |= ((img.at<uchar>(i-1,j)) > center) << 6;
code |= ((img.at<uchar>(i-1,j+1)) > center) << 5;
code |= ((img.at<uchar>(i,j+1)) > center) << 4;
code |= ((img.at<uchar>(i+1,j+1)) > center) << 3;
code |= ((img.at<uchar>(i+1,j)) > center) << 2;
code |= ((img.at<uchar>(i+1,j-1)) > center) << 1;
code |= ((img.at<uchar>(i,j-1)) > center) << 0;
dst.at<uchar>(i-1,j-1) = code;
}
}
return dst;
}
Thanks in advance.