0
我不知道如何使用之前聲明的函數,因爲它說無法派生模板參數爲T
;那是功能模板不匹配。但是,我如何使用該功能?這是代碼。無法爲「T」派生模板參數
#include<opencv2/opencv.hpp>
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
template <typename T> void getOriginLbp(InputArray _src, OutputArray _dst){
Mat src = _src.getMat();
_dst.create(src.rows - 2, src.cols - 2, CV_8UC1);
Mat dst = _dst.getMat();
dst.setTo(0);
for (int i = 1; i < src.rows - 1; i++)
{
for (int j = 1; j < src.cols - 1; j++)
{
T center = src.at<T>(i, j);
unsigned char lbpcode = 0;
lbpcode |= (src.at<T>(i - 1, j - 1)>center) << 7;
lbpcode |= (src.at<T>(i - 1, j)>center) << 6;
lbpcode |= (src.at<T>(i - 1, j + 1) > center) << 5;
lbpcode |= (src.at<T>(i, j + 1) > center) << 4;
lbpcode |= (src.at<T>(i + 1, j + 1) > center) << 3;
lbpcode |= (src.at<T>(i + 1, j) > center) << 2;
lbpcode |= (src.at<T>(i + 1, j - 1) > center) << 1;
lbpcode |= (src.at<T>(i, j - 1) > center);
dst.at<uchar>(i - 1, j - 1) = lbpcode;
}
}
}
int main()
{
Mat srcImg = imread("pep.jpg");
cvtColor(srcImg, srcImg, COLOR_BGR2GRAY);
Mat LbpImg;
getOriginLbp(srcImg, LbpImg);
imshow("originLbp", LbpImg);
return 0;
}
那麼SO如何使用getOriginLbp
函數?也許我使用了錯誤的參數?