Commit 1c82d1ec4a442662b31933a28ed61504324b346e
1 parent
590bb5d8
more code
Showing
2 changed files
with
48 additions
and
1 deletions
sdk/plugins/algorithms.cpp
| ... | ... | @@ -50,7 +50,7 @@ class AlgorithmsInitializer : public Initializer |
| 50 | 50 | Globals->abbreviations.insert("SmallSIFT", "Open+LimitSize(512)+KeyPointDetector(SIFT)+KeyPointDescriptor(SIFT):KeyPointMatcher(BruteForce)"); |
| 51 | 51 | Globals->abbreviations.insert("SmallSURF", "Open+LimitSize(512)+KeyPointDetector(SURF)+KeyPointDescriptor(SURF):KeyPointMatcher(BruteForce)"); |
| 52 | 52 | Globals->abbreviations.insert("ColorHist", "Open+LimitSize(512)!EnsureChannels(3)+SplitChannels+Hist(256,0,8)+Cat+Normalize(L1):L2"); |
| 53 | - 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"); | |
| 53 | + 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"); | |
| 54 | 54 | |
| 55 | 55 | // Hash |
| 56 | 56 | Globals->abbreviations.insert("FileName", "Name+Identity:Identical"); | ... | ... |
sdk/plugins/integral.cpp
| ... | ... | @@ -123,6 +123,53 @@ private: |
| 123 | 123 | |
| 124 | 124 | BR_REGISTER(Transform, GradientTransform) |
| 125 | 125 | |
| 126 | +/*! | |
| 127 | + * \ingroup transforms | |
| 128 | + * \brief Projects each row based on a computed word. | |
| 129 | + * \author Josh Klontz \cite jklontz | |
| 130 | + */ | |
| 131 | +class WordWiseTransform : public Transform | |
| 132 | +{ | |
| 133 | + Q_OBJECT | |
| 134 | + Q_PROPERTY(br::Transform* getWords READ get_getWords WRITE set_getWords RESET reset_getWords) | |
| 135 | + Q_PROPERTY(br::Transform* byWord READ get_byWord WRITE set_byWord RESET reset_byWord) | |
| 136 | + BR_PROPERTY(br::Transform*, getWords, NULL) | |
| 137 | + BR_PROPERTY(br::Transform*, byWord, NULL) | |
| 138 | + | |
| 139 | + void train(const TemplateList &data) | |
| 140 | + { | |
| 141 | + getWords->train(data); | |
| 142 | + TemplateList words; | |
| 143 | + getWords->project(data, words); | |
| 144 | + | |
| 145 | + const int columns = data.first().m().cols; | |
| 146 | + int numWords = 0; | |
| 147 | + foreach (const Template &t, words) { | |
| 148 | + double minVal, maxVal; | |
| 149 | + minMaxLoc(t, &minVal, &maxVal); | |
| 150 | + numWords = max(numWords, int(maxVal)+1); | |
| 151 | + } | |
| 152 | + | |
| 153 | + QVector<int> wordCounts(numWords, 0); | |
| 154 | + foreach (const Template &t, words) { | |
| 155 | + const Mat &m = t.m(); | |
| 156 | + for (int i=0; i<m.rows; i++) | |
| 157 | + wordCounts[m.at<uchar>(i,0)]++; | |
| 158 | + } | |
| 159 | + | |
| 160 | + QVector<Mat> trainingWords(numWords); | |
| 161 | + for (int i=0; i<numWords; i++) | |
| 162 | + trainingWords[i] = Mat(wordCounts[i], columns, CV_8UC1); | |
| 163 | + } | |
| 164 | + | |
| 165 | + void project(const Template &src, Template &dst) const | |
| 166 | + { | |
| 167 | + (void) src; (void) dst; | |
| 168 | + } | |
| 169 | +}; | |
| 170 | + | |
| 171 | +BR_REGISTER(Transform, WordWiseTransform) | |
| 172 | + | |
| 126 | 173 | } // namespace br |
| 127 | 174 | |
| 128 | 175 | #include "integral.moc" | ... | ... |