【发布时间】:2014-03-21 01:38:58
【问题描述】:
这里有很多关于 OpenCV 中的 calcHist 的问题,但我找不到我的问题的答案,并且已经阅读了好几次文档,所以希望有人能通过以下代码发现我的问题:
//the setup is that I've got a 1x993 cv::Mat called bestLabels that contains cluster
//labels for 993 features each belonging to 1 of 40 different clusters. I'm just trying
//to histogram these into hist.
cv::Mat hist;
int nbins = 40;
int hsize[] = { nbins };
float range[] = { 0, 39 };
const float *ranges[] = { range };
int chnls[] = { 0 };
cv::calcHist(&bestLabels, 1, chnls, cv::Mat(), hist, 1, hsize, ranges);
这可以编译,但是当我运行它时,我得到一个错误:
OpenCV Error: Unsupported format or combination of formats () in cv::calcHist
一开始很难让它编译,但现在我真的不确定我错过了什么。请帮忙!
另外,我曾尝试遍历 bestLabels 的元素,并只增加将存储我的直方图的数组中的值,但使用 bestLabels.at(0,i) 也不起作用。必须有一种更简单的方法来从 cv::Mat 对象中提取单个元素。
感谢您的帮助。
【问题讨论】: