Reputation: 1243
I used a function called 'calcHist' in opencv. And its declaration is:
void calcHist(const Mat* arrays, int narrays, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
I wrote a code snippets:
Mat img = imread("lena.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat* arrays = &img;
int narrays = 1;
int channels[] = { 0 };
InputArray mask = noArray();
Mat hist;
int dims = 1;
int histSize[] = { 256 };
float hranges[] = { 0.0, 255.0 };
float *ranges[] = { hranges };
calcHist(arrays, narrays, channels, mask, hist, dims, histSize, ranges);
and then got an error:IntelliSense: no instance of overloaded function "calcHist" matches the argument list
But if I prefix 'const' to 'float *ranges[] = {ranges};' like const float *ranges[] = { hranges };
it's okay.
So why this 'const' is necessary and the 'const' before histSize is not.
Upvotes: 0
Views: 497
Reputation:
T*
implicitly converts to const T*
. Correspondingly, this means T**
implicitly converts to T*const*
. T*const*
is not const T**
, so this conversion doesn't work to let you make the function call.
Upvotes: 1