From f3357e59608e4a4fae29a3811d2411c54d061dde Mon Sep 17 00:00:00 2001 From: Austin Van Blanton Date: Fri, 2 Aug 2013 09:40:59 -0400 Subject: [PATCH] Convert Mat if invalid type for hist --- openbr/plugins/hist.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openbr/plugins/hist.cpp b/openbr/plugins/hist.cpp index b3efd8b..d13fdee 100644 --- a/openbr/plugins/hist.cpp +++ b/openbr/plugins/hist.cpp @@ -52,8 +52,12 @@ class HistTransform : public UntrainableTransform int histSize[] = {dims}; float range[] = {min, max}; const float* ranges[] = {range}; - Mat hist; - calcHist(&mv[i], 1, channels, Mat(), hist, 1, histSize, ranges); + Mat hist, chan = mv[i]; + // calcHist requires F or U, might as well convert just in case + if (mv[i].depth() != CV_8U || mv[i].depth() == CV_32F) + mv[i].convertTo(chan, CV_32FC1); +// qDebug("clust r %i c %i ch %i", chan.rows, chan.cols, chan.channels()); + calcHist(&chan, 1, channels, Mat(), hist, 1, histSize, ranges); memcpy(m.ptr(i), hist.ptr(), dims * sizeof(float)); } -- libgit2 0.21.4