尝试对三通道图像进行直方图反投影会导致以下错误:
OpenCV 错误:histPrepareImages 中的断言失败(j < nimages),文件 ../modules/imgproc/src/histogram.cpp,第 148 行
失败的代码:
cv::Mat _refImage; //contains reference image of type CV_8UC3
cv::Mat output; //contains image data of type CV_8UC3
int histSize[] = {16, 16, 16};
int channels[] = {0, 1, 2};
const float hRange[] = {0.f, 256.f};
const float* ranges[] = {hRange, hRange, hRange};
int nChannels = 3;
cv::Mat hist;
cv::calcHist(&_refImage, 1, channels, cv::noArray(), hist, nChannels, histSize, ranges);
cv::calcBackProject(&output, 1, channels, hist, output, ranges); //This line causes assertion failure
在单通道图像上运行几乎相同的代码。根据文档,还支持多通道图像。为什么这段代码不起作用?