calcHist() using vectors
I am calculating a histogram from a greyscale image using the above code; it is working fine.
cv::Mat imgSrc = cv::imread("Image.jpg", cv::IMREAD_UNCHANGED); cv::Mat histogram; //Array for the histogram int channels[] = {0}; int binNumArray[] = {256}; float intensityRanges[] = { 0, 256 }; const float* ranges[] = { intensityRanges }; cv::calcHist( &imgSrc, 1, channels, cv::noArray(), histogram, 1, binNumArray, ranges, true, false) ;
In the book of Kaehler & Bradski they refer to this as the "old-fashioned C-style arrays" and they say the new style would use STL vector templates, and the arrays of images from which to calculate the histogram are to be given using cv::InputArrayOfArrays. However, if I try to replace for example the channel array by:
std::vector<int> channels {0};
Gives compilation error.So my questions are these: 1. How can I define the arrays of the 'channels', 'binNumArray', 'intensityRanges' using vectors? 2. How can I define the array of input images using cv::InputArrayOfArrays?
"and they say the new style would use STL vector templates" -- yea, it didn't happen ;(I figured it out in the meantime. The vector format does exist and does work, but the parameter list is different. With the vector format I must not provide the number of images (parameter 2 in the 'old' style.
oh, indeed