简体   繁体   English

在OpenCV中使用calcHist()函数的参数列表错误

[英]Argument list error using calcHist() function in OpenCV

I'm trying to use the following code: 我正在尝试使用以下代码:

    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 = &range;
    cv::calcHist(&frame.get<0>(), 1, &channel, cv::Mat(), hist, 1, &histSize, ranges, false, false);

The image is grayscale, so I'm using the zeroth channel to get the histogram, I know the range is uniform but I wanted to know my boundaries exactly, and the image is CV_16U type (in the original code the image is read from a camera, but that's too long to include here) 图像是灰度的,所以我正在使用第零个通道来获取直方图,我知道范围是均匀的,但是我想确切地知道边界,并且图像是CV_16U类型(在原始代码中,图像是从相机,但在此处无法包含在内)

My problem is that at compilation I get the following errors: 我的问题是在编译时出现以下错误:

    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)'

I know its kind of silly, but I'm about to go crazy. 我知道这很傻,但是我快要疯了。 Any help is appreciated. 任何帮助表示赞赏。 PS: I'm using opencv 2.4.2 on Microsoft Visual C++ express in 64-bit environment. PS:我在64位环境中的Microsoft Visual C ++ Express上使用opencv 2.4.2。

Best, 最好,

Baris 巴里斯

If your OpenCV version is newer than 2.3, which seems to be the case, you should know that cv::Mat and cv::MatND are combined. 如果您的OpenCV版本比2.3更高,那么您应该知道cv::Matcv::MatND是结合在一起的。

But about the error, as in the new OpenCV cv::Mat can have any number of dimensions, they have changed the definition, as you can see here : 但是关于错误,如新的OpenCV cv::Mat可以具有任意数量的尺寸,它们更改了定义,如您在此处看到的:

C++: void calcHist(const Mat* images, int nimages, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
C++: void calcHist(const Mat* images, int nimages, const int* channels, InputArray mask, SparseMat& hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )

You can also see in the brand new tutorial here , a simple cv::Mat would do the trick: 您还可以在这里的全新教程中看到一个简单的cv::Mat可以解决问题:

cv::Mat hist;

Using the new documentation would help you clear these things up, unfortunately most of the tutorials and codes available are based on the old OpenCV which has undertaken big changes to get to the current version. 使用新的文档将帮助您清除这些问题,不幸的是,大多数可用的教程和代码都是基于旧的OpenCV的,该版本已进行了较大的更改以更新到当前版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误C3867:函数调用缺少参数列表 - Error C3867: function call missing argument list 将CalcOpticalFlowPyrLK与OpenCV 2.3.1结合使用时出错 - Error using calcOpticalFlowPyrLK with OpenCV 2.3.1 使用Visual Studio 2010和OpenCV 2.2的CvAcc函数中的“未处理的异常(KernelBase.dll)”错误 - “Unhandled exception (KernelBase.dll) ” error in CvAcc function using visual studio 2010 and opencv 2.2 不止一个重载 function 实例与参数列表匹配,我找不到错误发生的位置 - More than one instance of overloaded function matches the argument list and I can't find where the error happens 使用变量参数列表将值分配给传递的引用(VS2010中的错误) - Assigning value to passed references using variable argument list (error in VS2010) 如何使用opencv创建cvSobel函数 - How to create cvSobel function using opencv 使用OpenCV进行视频捕获时发生执行错误 - Execution Error using OpenCV for video Capturing 使用VideoWriter_GPU时,如何解决“未实现的OpenCV错误”功能(当前版本或平台已禁用所谓的功能)? - How to solve OpenCV Error "function not implemented (called functionality is disabled for current build or platform) when using VideoWriter_GPU? 使用静态模板函数使用函数的默认参数编译错误 - Compile error with default argument of function with static template function OpenCV错误 - Error with OpenCV
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM