我正在尝试使用以下代码:
cv::MatND hist;
cv::Mat image = cv::imread("image.bmp");
float *range = new float[33];
int histSize = 32;
int channel = 0;
for (int i = 0; i < 33; ++i)
range[i] = (float)6602.0 + 21*i;
float **ranges = ⦥
cv::calcHist(&frame.get<0>(), 1, &channel, cv::Mat(), hist, 1, &histSize, ranges, false, false);
图像是灰度的,所以我使用第零个通道来获取直方图,我知道范围是统一的,但我想准确地知道我的边界,并且图像是 CV_16U 类型(在原始代码中,图像是从相机,但这太长了,不能在这里包含)
我的问题是在编译时出现以下错误:
error C2665: 'cv::calcHist' : none of the 3 overloads could convert all the argument types
C:\opencv\build_x64\include\opencv2/imgproc/imgproc.hpp(670): could be 'void cv::calcHist(const cv::Mat *,int,const int *,cv::InputArray,cv::OutputArray,int,const int *,const float **,bool,bool)'
C:\opencv\build_x64\include\opencv2/imgproc/imgproc.hpp(676): or 'void cv::calcHist(const cv::Mat *,int,const int *,cv::InputArray,cv::SparseMat &,int,const int *,const float **,bool,bool)'
while trying to match the argument list '(cv::Mat *, int, int *, cv::Mat, cv::MatND, int, int *, float **, bool, bool)'
我知道这有点傻,但我快要发疯了。任何帮助表示赞赏。PS:我在 64 位环境中的 Microsoft Visual C++ express 上使用 opencv 2.4.2。
最好的,
巴里斯