Commit f3357e59608e4a4fae29a3811d2411c54d061dde
1 parent
dfc7cd72
Convert Mat if invalid type for hist
Showing
1 changed file
with
6 additions
and
2 deletions
openbr/plugins/hist.cpp
| ... | ... | @@ -52,8 +52,12 @@ class HistTransform : public UntrainableTransform |
| 52 | 52 | int histSize[] = {dims}; |
| 53 | 53 | float range[] = {min, max}; |
| 54 | 54 | const float* ranges[] = {range}; |
| 55 | - Mat hist; | |
| 56 | - calcHist(&mv[i], 1, channels, Mat(), hist, 1, histSize, ranges); | |
| 55 | + Mat hist, chan = mv[i]; | |
| 56 | + // calcHist requires F or U, might as well convert just in case | |
| 57 | + if (mv[i].depth() != CV_8U || mv[i].depth() == CV_32F) | |
| 58 | + mv[i].convertTo(chan, CV_32FC1); | |
| 59 | +// qDebug("clust r %i c %i ch %i", chan.rows, chan.cols, chan.channels()); | |
| 60 | + calcHist(&chan, 1, channels, Mat(), hist, 1, histSize, ranges); | |
| 57 | 61 | memcpy(m.ptr(i), hist.ptr(), dims * sizeof(float)); |
| 58 | 62 | } |
| 59 | 63 | ... | ... |