diff --git a/sdk/plugins/algorithms.cpp b/sdk/plugins/algorithms.cpp index 0f28273..526bcb7 100644 --- a/sdk/plugins/algorithms.cpp +++ b/sdk/plugins/algorithms.cpp @@ -50,7 +50,7 @@ class AlgorithmsInitializer : public Initializer Globals->abbreviations.insert("SmallSIFT", "Open+LimitSize(512)+KeyPointDetector(SIFT)+KeyPointDescriptor(SIFT):KeyPointMatcher(BruteForce)"); Globals->abbreviations.insert("SmallSURF", "Open+LimitSize(512)+KeyPointDetector(SURF)+KeyPointDescriptor(SURF):KeyPointMatcher(BruteForce)"); Globals->abbreviations.insert("ColorHist", "Open+LimitSize(512)!EnsureChannels(3)+SplitChannels+Hist(256,0,8)+Cat+Normalize(L1):L2"); - Globals->abbreviations.insert("IHH", "Open+(RG+MAdd(0.5))/(Cvt(Gray)+Gradient+Bin(0,360,8,true))+Merge+Integral+IntegralSampler+CvtFloat+RowWisePCA(8)+RowWiseMeanCenter+Binarize:L2"); + Globals->abbreviations.insert("IHH", "Open+(RG+MAdd(0.5))/(Cvt(Gray)+Gradient+Bin(0,360,8,true))+Merge+Integral+IntegralSampler+CvtFloat+WordWise(RowWisePCA(8)+RowWiseMeanCenter+Binarize,Identity):L2"); // Hash Globals->abbreviations.insert("FileName", "Name+Identity:Identical"); diff --git a/sdk/plugins/integral.cpp b/sdk/plugins/integral.cpp index 6b4eb2b..d369cc9 100644 --- a/sdk/plugins/integral.cpp +++ b/sdk/plugins/integral.cpp @@ -123,6 +123,53 @@ private: BR_REGISTER(Transform, GradientTransform) +/*! + * \ingroup transforms + * \brief Projects each row based on a computed word. + * \author Josh Klontz \cite jklontz + */ +class WordWiseTransform : public Transform +{ + Q_OBJECT + Q_PROPERTY(br::Transform* getWords READ get_getWords WRITE set_getWords RESET reset_getWords) + Q_PROPERTY(br::Transform* byWord READ get_byWord WRITE set_byWord RESET reset_byWord) + BR_PROPERTY(br::Transform*, getWords, NULL) + BR_PROPERTY(br::Transform*, byWord, NULL) + + void train(const TemplateList &data) + { + getWords->train(data); + TemplateList words; + getWords->project(data, words); + + const int columns = data.first().m().cols; + int numWords = 0; + foreach (const Template &t, words) { + double minVal, maxVal; + minMaxLoc(t, &minVal, &maxVal); + numWords = max(numWords, int(maxVal)+1); + } + + QVector wordCounts(numWords, 0); + foreach (const Template &t, words) { + const Mat &m = t.m(); + for (int i=0; i(i,0)]++; + } + + QVector trainingWords(numWords); + for (int i=0; i